Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to include word based suggestions regardless of the language #110494

Merged
merged 1 commit into from Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/vs/editor/common/config/commonEditorConfig.ts
Expand Up @@ -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.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking, good. I might remodel this into a enum which goes like wordBasedSuggestionSource: 'currentDocument', 'sameLanguageDocuments', 'allDocuments'. That will allow folks to go back to old behaviour as well

},
'editor.semanticHighlighting.enabled': {
enum: [true, false, 'configuredByTheme'],
enumDescriptions: [
Expand Down
4 changes: 3 additions & 1 deletion src/vs/editor/common/services/editorWorkerServiceImpl.ts
Expand Up @@ -148,7 +148,7 @@ class WordBasedCompletionItemProvider implements modes.CompletionItemProvider {
}

async provideCompletionItems(model: ITextModel, position: Position): Promise<modes.CompletionList | undefined> {
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;
}
Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions src/vs/editor/standalone/browser/standaloneCodeEditor.ts
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/vs/monaco.d.ts
Expand Up @@ -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
Expand Down