From 8732e235927f91837942e85a9d5375222a082c1c Mon Sep 17 00:00:00 2001 From: Jason Dent Date: Wed, 8 Jan 2025 12:54:55 +0100 Subject: [PATCH] fix: Have a single setting to hide issues in ruler (#4028) --- package.json | 7 +++++++ .../_server/spell-checker-config.schema.json | 8 ++++++++ .../config/cspellConfig/AppearanceSettings.mts | 11 +++++++++++ .../src/config/cspellConfig/configFields.mts | 1 + .../client/src/decorators/decorateIssues.mts | 18 +++++++++++------- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 4409966a81..f88cd323b4 100644 --- a/package.json +++ b/package.json @@ -3191,6 +3191,13 @@ "since": "4.0.0", "type": "string" }, + "cSpell.showInRuler": { + "default": true, + "markdownDescription": "Show spelling issues in the editor ruler.\n\nNote: This setting is only used when `#cSpell.useCustomDecorations#` is `true`.", + "scope": "application", + "since": "4.0.35", + "type": "boolean" + }, "cSpell.textDecoration": { "markdownDescription": "The CSS Style used to decorate spelling issues. Depends upon `#cSpell.useCustomDecorations#`.\n\nThis setting is used to manually configure the text decoration. If it is not set, the following settings are used:\n- `#cSpell.textDecorationLine#` to pick the line type\n- `#cSpell.textDecorationStyle#` to pick the style\n- `#cSpell.textDecorationColor#` to set the color\n- `#cSpell.textDecorationThickness#` to set the thickness.\n\nSee: [text-decoration - CSS: Cascading Style Sheets, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration)\n\nFormat: ` [style] [thickness]`\n\n- line - `underline`, `overline`, see: [text-decoration-line, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-line)\n- style - `solid`, `wavy`, `dotted`, see: [text-decoration-style, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-style)\n- color - see: [text-decoration-color, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color)\n- thickness - see: [text-decoration-thickness, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-thickness)\n\nExamples:\n- `underline green`\n- `underline dotted yellow 0.2rem`\n- `underline wavy #ff0c 1.5px` - Wavy underline with 1.5px thickness in semi-transparent yellow.\n\nTo change the ruler color, use `#cSpell.overviewRulerColor#`.", "scope": "application", diff --git a/packages/_server/spell-checker-config.schema.json b/packages/_server/spell-checker-config.schema.json index 4eb1cecb94..88e4c52c35 100644 --- a/packages/_server/spell-checker-config.schema.json +++ b/packages/_server/spell-checker-config.schema.json @@ -2781,6 +2781,14 @@ "since": "4.0.0", "type": "string" }, + "cSpell.showInRuler": { + "default": true, + "description": "Show spelling issues in the editor ruler.\n\nNote: This setting is only used when `#cSpell.useCustomDecorations#` is `true`.", + "markdownDescription": "Show spelling issues in the editor ruler.\n\nNote: This setting is only used when `#cSpell.useCustomDecorations#` is `true`.", + "scope": "application", + "since": "4.0.35", + "type": "boolean" + }, "cSpell.textDecoration": { "description": "The CSS Style used to decorate spelling issues. Depends upon `#cSpell.useCustomDecorations#`.\n\nThis setting is used to manually configure the text decoration. If it is not set, the following settings are used:\n- `#cSpell.textDecorationLine#` to pick the line type\n- `#cSpell.textDecorationStyle#` to pick the style\n- `#cSpell.textDecorationColor#` to set the color\n- `#cSpell.textDecorationThickness#` to set the thickness.\n\nSee: [text-decoration - CSS: Cascading Style Sheets, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration)\n\nFormat: ` [style] [thickness]`\n\n- line - `underline`, `overline`, see: [text-decoration-line, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-line)\n- style - `solid`, `wavy`, `dotted`, see: [text-decoration-style, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-style)\n- color - see: [text-decoration-color, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color)\n- thickness - see: [text-decoration-thickness, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-thickness)\n\nExamples:\n- `underline green`\n- `underline dotted yellow 0.2rem`\n- `underline wavy #ff0c 1.5px` - Wavy underline with 1.5px thickness in semi-transparent yellow.\n\nTo change the ruler color, use `#cSpell.overviewRulerColor#`.", "markdownDescription": "The CSS Style used to decorate spelling issues. Depends upon `#cSpell.useCustomDecorations#`.\n\nThis setting is used to manually configure the text decoration. If it is not set, the following settings are used:\n- `#cSpell.textDecorationLine#` to pick the line type\n- `#cSpell.textDecorationStyle#` to pick the style\n- `#cSpell.textDecorationColor#` to set the color\n- `#cSpell.textDecorationThickness#` to set the thickness.\n\nSee: [text-decoration - CSS: Cascading Style Sheets, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration)\n\nFormat: ` [style] [thickness]`\n\n- line - `underline`, `overline`, see: [text-decoration-line, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-line)\n- style - `solid`, `wavy`, `dotted`, see: [text-decoration-style, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-style)\n- color - see: [text-decoration-color, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color)\n- thickness - see: [text-decoration-thickness, MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-thickness)\n\nExamples:\n- `underline green`\n- `underline dotted yellow 0.2rem`\n- `underline wavy #ff0c 1.5px` - Wavy underline with 1.5px thickness in semi-transparent yellow.\n\nTo change the ruler color, use `#cSpell.overviewRulerColor#`.", diff --git a/packages/_server/src/config/cspellConfig/AppearanceSettings.mts b/packages/_server/src/config/cspellConfig/AppearanceSettings.mts index bfaa41c7ea..fe010a1bf7 100644 --- a/packages/_server/src/config/cspellConfig/AppearanceSettings.mts +++ b/packages/_server/src/config/cspellConfig/AppearanceSettings.mts @@ -182,6 +182,17 @@ interface Appearance extends Decoration { } export interface AppearanceSettings extends Appearance { + /** + * Show spelling issues in the editor ruler. + * + * Note: This setting is only used when `#cSpell.useCustomDecorations#` is `true`. + * + * @scope application + * @since 4.0.35 + * @default true + */ + showInRuler?: boolean; + /** * Draw custom decorations on Spelling Issues. * - `true` - Use custom decorations. - VS Code Diagnostic Severity Levels are not used. diff --git a/packages/_server/src/config/cspellConfig/configFields.mts b/packages/_server/src/config/cspellConfig/configFields.mts index 98a99a2e99..e3563a3704 100644 --- a/packages/_server/src/config/cspellConfig/configFields.mts +++ b/packages/_server/src/config/cspellConfig/configFields.mts @@ -65,6 +65,7 @@ export const ConfigFields: CSpellUserSettingsFields = { // Appearance useCustomDecorations: 'useCustomDecorations', doNotUseCustomDecorationForScheme: 'doNotUseCustomDecorationForScheme', + showInRuler: 'showInRuler', textDecoration: 'textDecoration', textDecorationLine: 'textDecorationLine', textDecorationStyle: 'textDecorationStyle', diff --git a/packages/client/src/decorators/decorateIssues.mts b/packages/client/src/decorators/decorateIssues.mts index 946f6644e2..4a55df61ba 100644 --- a/packages/client/src/decorators/decorateIssues.mts +++ b/packages/client/src/decorators/decorateIssues.mts @@ -249,6 +249,7 @@ export class SpellingIssueDecorator implements Disposable { | 'light' | 'overviewRulerColor' | 'revealIssuesAfterDelayMS' + | 'showInRuler' | 'textDecoration' | 'textDecorationColor' | 'textDecorationColorFlagged' @@ -258,29 +259,32 @@ export class SpellingIssueDecorator implements Disposable { | 'textDecorationThickness' >; - const overviewRulerColor: string | undefined = cfg[mode]?.overviewRulerColor || cfg.overviewRulerColor || undefined; + const showInRuler = cfg.showInRuler ?? true; + const overviewRulerColor: string | undefined = + (showInRuler && (cfg[mode]?.overviewRulerColor || cfg.overviewRulerColor)) || undefined; + const overviewRulerLane = showInRuler ? vscode.OverviewRulerLane.Right : undefined; const decoratorIssues = window.createTextEditorDecorationType({ isWholeLine: false, rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed, - overviewRulerLane: vscode.OverviewRulerLane.Right, - overviewRulerColor: overviewRulerColor, + overviewRulerLane, + overviewRulerColor, textDecoration: calcTextDecoration(cfg, mode, 'textDecorationColor'), }); const decoratorFlagged = window.createTextEditorDecorationType({ isWholeLine: false, rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed, - overviewRulerLane: vscode.OverviewRulerLane.Right, - overviewRulerColor: overviewRulerColor, + overviewRulerLane, + overviewRulerColor, textDecoration: calcTextDecoration(cfg, mode, 'textDecorationColorFlagged'), }); const decoratorSuggestions = window.createTextEditorDecorationType({ isWholeLine: false, rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed, - overviewRulerLane: vscode.OverviewRulerLane.Right, - overviewRulerColor: overviewRulerColor, + overviewRulerLane, + overviewRulerColor, textDecoration: calcTextDecoration(cfg, mode, 'textDecorationColorSuggestion'), });