Skip to content

Commit

Permalink
feat: Move Spelling Menu items into a submenu (#2121)
Browse files Browse the repository at this point in the history
- Move all spelling commands into a `Spelling` submenu
- Add a setting to show suggestions in the context menu: `cSpell. showSuggestionsLinkInEditorContextMenu`
- Adjust order of the spelling commands
  • Loading branch information
Jason3S authored Aug 6, 2022
1 parent 88856f0 commit e760c1b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 21 deletions.
46 changes: 33 additions & 13 deletions docs/_includes/generated-docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,20 @@ Default

# Reporting and Display

| Setting | Scope | Description |
| ---------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------- |
| [`cSpell.diagnosticLevel`](#cspelldiagnosticlevel) | resource | Set Diagnostic Reporting Level |
| [`cSpell.maxDuplicateProblems`](#cspellmaxduplicateproblems) | resource | The maximum number of times the same word can be flagged as an error in a file. |
| [`cSpell.maxNumberOfProblems`](#cspellmaxnumberofproblems) | resource | Controls the maximum number of spelling errors per document. |
| [`cSpell.minWordLength`](#cspellminwordlength) | resource | The minimum length of a word before checking it against a dictionary. |
| [`cSpell.numSuggestions`](#cspellnumsuggestions) | resource | Controls the number of suggestions shown. |
| [`cSpell.showAutocompleteSuggestions`](#cspellshowautocompletesuggestions) | language-overridable | Show CSpell in-document directives as you type. |
| [`cSpell.showCommandsInEditorContextMenu`](#cspellshowcommandsineditorcontextmenu) | application | Show Spell Checker actions in Editor Context Menu |
| [`cSpell.showStatus`](#cspellshowstatus) | application | Display the spell checker status on the status bar. |
| [`cSpell.showStatusAlignment`](#cspellshowstatusalignment) | application | The side of the status bar to display the spell checker status. |
| [`cSpell.suggestionMenuType`](#cspellsuggestionmenutype) | resource | The type of menu used to display spelling suggestions. |
| [`cSpell.suggestionNumChanges`](#cspellsuggestionnumchanges) | resource | The maximum number of changes allowed on a word to be considered a suggestions. |
| Setting | Scope | Description |
| ------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------- |
| [`cSpell.diagnosticLevel`](#cspelldiagnosticlevel) | resource | Set Diagnostic Reporting Level |
| [`cSpell.maxDuplicateProblems`](#cspellmaxduplicateproblems) | resource | The maximum number of times the same word can be flagged as an error in a file. |
| [`cSpell.maxNumberOfProblems`](#cspellmaxnumberofproblems) | resource | Controls the maximum number of spelling errors per document. |
| [`cSpell.minWordLength`](#cspellminwordlength) | resource | The minimum length of a word before checking it against a dictionary. |
| [`cSpell.numSuggestions`](#cspellnumsuggestions) | resource | Controls the number of suggestions shown. |
| [`cSpell.showAutocompleteSuggestions`](#cspellshowautocompletesuggestions) | language-overridable | Show CSpell in-document directives as you type. |
| [`cSpell.showCommandsInEditorContextMenu`](#cspellshowcommandsineditorcontextmenu) | application | Show Spell Checker actions in Editor Context Menu |
| [`cSpell.showStatus`](#cspellshowstatus) | application | Display the spell checker status on the status bar. |
| [`cSpell.showStatusAlignment`](#cspellshowstatusalignment) | application | The side of the status bar to display the spell checker status. |
| [`cSpell.showSuggestionsLinkInEditorConte…`](#cspellshowsuggestionslinkineditorcontextmenu) | application | Show Spelling Suggestions link in the top level context menu. |
| [`cSpell.suggestionMenuType`](#cspellsuggestionmenutype) | resource | The type of menu used to display spelling suggestions. |
| [`cSpell.suggestionNumChanges`](#cspellsuggestionnumchanges) | resource | The maximum number of changes allowed on a word to be considered a suggestions. |

## Definitions

Expand Down Expand Up @@ -494,6 +495,25 @@ Default

---

### `cSpell.showSuggestionsLinkInEditorContextMenu`

Name
: `cSpell.showSuggestionsLinkInEditorContextMenu`

Type
: boolean

Scope
: application

Description
: Show Spelling Suggestions link in the top level context menu.

Default
: _`true`_

---

### `cSpell.suggestionMenuType`

Name
Expand Down
54 changes: 47 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@
"editor/context": [
{
"command": "cSpell.suggestSpellingCorrections",
"when": "editorTextFocus && cSpell.editorMenuContext.showSuggestions",
"when": "editorTextFocus && config.cSpell.showSuggestionsLinkInEditorContextMenu && cSpell.editorMenuContext.showSuggestions",
"group": "A_cspell@000"
},
{
"submenu": "cSpell.spelling",
"group": "A_cspell@001",
"when": "editorTextFocus && config.cSpell.showCommandsInEditorContextMenu"
}
],
"cSpell.spelling": [
{
"command": "cSpell.suggestSpellingCorrections",
"when": "editorTextFocus && !config.cSpell.showSuggestionsLinkInEditorContextMenu && cSpell.editorMenuContext.showSuggestions",
"group": "A_cspell@001"
},
{
Expand Down Expand Up @@ -99,20 +111,32 @@
"when": "editorTextFocus && cSpell.editorMenuContext.addIssuesToDictionary",
"group": "A_cspell@060"
},
{
"command": "cSpell.addIgnoreWord",
"when": "editorTextFocus && cSpell.editorMenuContext.addIgnoreWord",
"group": "A_cspell@090"
},
{
"command": "cSpell.createCSpellConfig",
"when": "editorTextFocus && cSpell.editorMenuContext.createCSpellConfig",
"group": "B_cspell@010"
},
{
"command": "cSpell.createCustomDictionary",
"when": "editorTextFocus && cSpell.editorMenuContext.createCustomDictionary",
"group": "A_cspell@070"
},
"group": "B_cspell@020"
}
],
"cSpell.configMenu": [
{
"command": "cSpell.createCSpellConfig",
"when": "editorTextFocus && cSpell.editorMenuContext.createCSpellConfig",
"group": "A_cspell@080"
"group": "A_cspell@010"
},
{
"command": "cSpell.addIgnoreWord",
"when": "editorTextFocus && cSpell.editorMenuContext.addIgnoreWord",
"group": "A_cspell@090"
"command": "cSpell.createCustomDictionary",
"when": "editorTextFocus && cSpell.editorMenuContext.createCustomDictionary",
"group": "A_cspell@070"
}
],
"commandPalette": [
Expand All @@ -133,6 +157,16 @@
}
]
},
"submenus": [
{
"id": "cSpell.spelling",
"label": "Spelling"
},
{
"id": "cSpell.configMenu",
"label": "Spell Checker Configuration"
}
],
"viewsContainers": {
"activitybar": [
{
Expand Down Expand Up @@ -2152,6 +2186,12 @@
"scope": "application",
"type": "string"
},
"cSpell.showSuggestionsLinkInEditorContextMenu": {
"default": true,
"description": "Show Spelling Suggestions link in the top level context menu.",
"scope": "application",
"type": "boolean"
},
"cSpell.suggestionMenuType": {
"default": "quickPick",
"enum": [
Expand Down
6 changes: 6 additions & 0 deletions packages/_server/spell-checker-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,12 @@
"scope": "application",
"type": "string"
},
"cSpell.showSuggestionsLinkInEditorContextMenu": {
"default": true,
"description": "Show Spelling Suggestions link in the top level context menu.",
"scope": "application",
"type": "boolean"
},
"cSpell.suggestionMenuType": {
"default": "quickPick",
"enum": [
Expand Down
8 changes: 8 additions & 0 deletions packages/_server/src/config/cspellConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ export interface SpellCheckerSettings extends SpellCheckerShouldCheckDocSettings
*/
showCommandsInEditorContextMenu?: boolean;

/**
* Show Spelling Suggestions link in the top level context menu.
* @scope application
* @default true
*/
showSuggestionsLinkInEditorContextMenu?: boolean;

/**
* @title File Types to Check
* @scope resource
Expand Down Expand Up @@ -1004,6 +1011,7 @@ type _VSConfigReporting = Pick<
| 'showCommandsInEditorContextMenu'
| 'showStatus'
| 'showStatusAlignment'
| 'showSuggestionsLinkInEditorContextMenu'
| 'suggestionMenuType'
| 'suggestionNumChanges'
>;
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ async function _updateDocumentRelatedContext(client: CSpellClient, doc: TextDocu
context.editorMenuContext.createCSpellConfig = show && showCreateConfig;
context.editorMenuContext.addIgnoreWord = show && hasIssues;

context.editorMenuContext.showSuggestions = show && hasIssues;
context.editorMenuContext.showSuggestions = (show || cfg.settings?.showSuggestionsLinkInEditorContextMenu || false) && hasIssues;

await setContext(context);
return;
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/settings/configFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const ConfigFields: CSpellUserSettingsFields = {
showCommandsInEditorContextMenu: 'showCommandsInEditorContextMenu',
showStatus: 'showStatus',
showStatusAlignment: 'showStatusAlignment',
showSuggestionsLinkInEditorContextMenu: 'showSuggestionsLinkInEditorContextMenu',
spellCheckDelayMs: 'spellCheckDelayMs',
spellCheckOnlyWorkspaceFiles: 'spellCheckOnlyWorkspaceFiles',
suggestionMenuType: 'suggestionMenuType',
Expand Down

0 comments on commit e760c1b

Please sign in to comment.