Skip to content

Commit

Permalink
Do not show rule list for prefix selectors by default
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Feb 8, 2025
1 parent 42ba034 commit 0b2cb1e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ internal class RuffConfigurations : DisplayableState() {

var autoRestartServers by property(true)
var snoozeFormattingTaskError by property(false)
var showRuleListForPrefixSelectors by property(false)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ private fun Row.snoozeFormattingTaskErrorInput(block: Cell<JBCheckBox>.() -> Uni
checkBox(message("configurations.ruff.snoozeFormattingTaskError.label")).apply(block)


private fun Row.showRuleListForPrefixSelectorsInput(block: Cell<JBCheckBox>.() -> Unit) =
checkBox(message("configurations.ruff.showRuleListForPrefixSelectors.label")).apply(block)


@Suppress("DialogTitleCapitalization")
private fun RuffPanel.makeComponent() = panel {

Expand Down Expand Up @@ -330,6 +334,10 @@ private fun RuffPanel.makeComponent() = panel {
snoozeFormattingTaskErrorInput { bindSelected(state::snoozeFormattingTaskError) }
overrideCheckbox(state::snoozeFormattingTaskError)
}
row {
showRuleListForPrefixSelectorsInput { bindSelected(state::showRuleListForPrefixSelectors) }
overrideCheckbox(state::showRuleListForPrefixSelectors)
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import insyncwithfoo.ryecharm.HTML
import insyncwithfoo.ryecharm.Markdown
import insyncwithfoo.ryecharm.ProgressContext
import insyncwithfoo.ryecharm.completedAbnormally
import insyncwithfoo.ryecharm.configurations.ruff.ruffConfigurations
import insyncwithfoo.ryecharm.isSuccessful
import insyncwithfoo.ryecharm.message
import insyncwithfoo.ryecharm.parseAsJSON
Expand Down Expand Up @@ -150,6 +151,10 @@ private suspend fun Project.getRuleDocumentationByRuleName(name: RuleName) =


private suspend fun Project.getRuleListByPrefix(selector: RuleSelector): Markdown? {
if (!ruffConfigurations.showRuleListForPrefixSelectors) {
return null
}

val nameToCodeMap = getRuleNameToCodeMap() ?: return null
val ruleList = StringBuilder()

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/messages/ryecharm.properties
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ configurations.ruff.suggestExecutableOnPackagesChange.label = Packages change

configurations.ruff.autoRestartServers.label = Automatically restart servers on configuration change
configurations.ruff.snoozeFormattingTaskError.label = Do not notify when formatting fails
configurations.ruff.showRuleListForPrefixSelectors.label = \
Show matching rules for prefix selectors on hover (might be incorrect)

######################################## endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class RuffConfigurationsTest : ConfigurationsTest<RuffConfigurations>()

@Test
fun `test shape`() {
doShapeTest(expectedSize = 30) {
doShapeTest(expectedSize = 32) {
assertEquals(null, executable)
assertEquals(true, crossPlatformExecutableResolution)
assertEquals(null, configurationFile)
Expand Down Expand Up @@ -51,6 +51,7 @@ internal class RuffConfigurationsTest : ConfigurationsTest<RuffConfigurations>()

assertEquals(true, autoRestartServers)
assertEquals(false, snoozeFormattingTaskError)
assertEquals(false, showRuleListForPrefixSelectors)
}
}

Expand Down

0 comments on commit 0b2cb1e

Please sign in to comment.