Skip to content

Commit

Permalink
fix: Do not show context menu if editorReadonly (#2590)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Mar 14, 2023
1 parent 23a0df9 commit 86aeafd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
"editor/context": [
{
"command": "cSpell.suggestSpellingCorrections",
"when": "editorTextFocus && config.cSpell.showSuggestionsLinkInEditorContextMenu && cSpell.editorMenuContext.showSuggestions",
"when": "!editorReadonly && editorTextFocus && config.cSpell.showSuggestionsLinkInEditorContextMenu && cSpell.editorMenuContext.showSuggestions",
"group": "A_cspell@000"
},
{
"submenu": "cSpell.spelling",
"group": "A_cspell@001",
"when": "editorTextFocus && config.cSpell.showCommandsInEditorContextMenu"
"when": "!editorReadonly && editorTextFocus && config.cSpell.showCommandsInEditorContextMenu"
}
],
"cSpell.spelling": [
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const defaultEditorMenuContext: EditorMenuContext = Object.freeze({
addIgnoreWord: false,
});

const allowContextMenuForScheme: Record<string, boolean | undefined> = {
output: false,
};

/**
* Set context values
* @param name - name of context to set
Expand Down Expand Up @@ -119,6 +123,10 @@ export async function updateDocumentRelatedContext(client: CSpellClient, doc: Te
return;
}

if (allowContextMenuForScheme[doc.uri.scheme] === false) {
return;
}

const _doc = doc;

const cached = cachedUpdateDocumentRelatedContext.get(_doc);
Expand Down

0 comments on commit 86aeafd

Please sign in to comment.