diff --git a/src/vs/editor/common/config/commonEditorConfig.ts b/src/vs/editor/common/config/commonEditorConfig.ts index 3bde5dfd839a3c960b6431812739c09c3fd00199..f9bf0b49449a3b722896cb34476fb5b312f670ee 100644 --- a/src/vs/editor/common/config/commonEditorConfig.ts +++ b/src/vs/editor/common/config/commonEditorConfig.ts @@ -502,6 +502,11 @@ const editorConfiguration: IConfigurationNode = { default: true, description: nls.localize('wordBasedSuggestions', "Controls whether completions should be computed based on words in the document.") }, + 'editor.wordBasedSuggestionsOnlySameLanguage': { + type: 'boolean', + default: true, + description: nls.localize('wordBasedSuggestionsOnlySameLanguage', "Controls whether word based completions should be included from opened documents of the same language or any language.") + }, 'editor.semanticHighlighting.enabled': { enum: [true, false, 'configuredByTheme'], enumDescriptions: [ diff --git a/src/vs/editor/common/services/editorWorkerServiceImpl.ts b/src/vs/editor/common/services/editorWorkerServiceImpl.ts index 55171bef77d1dcbd6292e474161e4db49cd12c82..72508f18d199517cf2bba0251b220a2e0c0575bf 100644 --- a/src/vs/editor/common/services/editorWorkerServiceImpl.ts +++ b/src/vs/editor/common/services/editorWorkerServiceImpl.ts @@ -148,7 +148,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider { } async provideCompletionItems(model: ITextModel, position: Position): Promise { - const { wordBasedSuggestions } = this._configurationService.getValue<{ wordBasedSuggestions?: boolean }>(model.uri, position, 'editor'); + const { wordBasedSuggestions, wordBasedSuggestionsOnlySameLanguage } = this._configurationService.getValue<{ wordBasedSuggestions?: boolean, wordBasedSuggestionsOnlySameLanguage?: boolean }>(model.uri, position, 'editor'); if (!wordBasedSuggestions) { return undefined; } @@ -160,6 +160,8 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider { } if (candidate === model) { models.unshift(candidate.uri); + } else if (!wordBasedSuggestionsOnlySameLanguage) { + models.push(candidate.uri); } else if (candidate.getLanguageIdentifier().id === model.getLanguageIdentifier().id) { models.push(candidate.uri); } diff --git a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts index e06bd35a8d0e7909a58904f254e6405357be9f15..9344ee801c6a40b985a7909d115375b06b3bf3ed 100644 --- a/src/vs/editor/standalone/browser/standaloneCodeEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneCodeEditor.ts @@ -113,6 +113,10 @@ export interface IGlobalEditorOptions { * Defaults to true. */ wordBasedSuggestions?: boolean; + /** + * Controls whether word based completions should be included from opened documents of the same language or any language. + */ + wordBasedSuggestionsOnlySameLanguage?: boolean; /** * Controls whether the semanticHighlighting is shown for the languages that support it. * true: semanticHighlighting is enabled for all themes diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index f8ce89f9be1700a3fddd049c3f8e603a9cfe6cab..406fe98a2ebc4e00b82d14227178285868db4763 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -1115,6 +1115,10 @@ declare namespace monaco.editor { * Defaults to true. */ wordBasedSuggestions?: boolean; + /** + * Controls whether word based completions should be included from opened documents of the same language or any language. + */ + wordBasedSuggestionsOnlySameLanguage?: boolean; /** * Controls whether the semanticHighlighting is shown for the languages that support it. * true: semanticHighlighting is enabled for all themes