Skip to content

Commit 0c6b128

Browse files
authored
Add editor.inlineSuggest.experimental.suppressInlineSuggestions (microsoft#249968)
1 parent d306ba0 commit 0c6b128

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/vs/editor/common/config/editorOptions.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,13 @@ class EditorEnumOption<K extends EditorOption, T extends string, V> extends Base
13571357
}
13581358
}
13591359

1360+
function stringArray(value: any, defaultValue: string[]): string[] {
1361+
if (!Array.isArray(value)) {
1362+
return defaultValue;
1363+
}
1364+
return value.map(item => String(item));
1365+
}
1366+
13601367
//#endregion
13611368

13621369
//#region autoIndent
@@ -4274,6 +4281,16 @@ export interface IInlineSuggestOptions {
42744281
*/
42754282
useMultiLineGhostText?: boolean;
42764283
};
4284+
4285+
/**
4286+
* @internal
4287+
*/
4288+
experimental?: {
4289+
/**
4290+
* @internal
4291+
*/
4292+
suppressInlineSuggestions?: string[];
4293+
};
42774294
}
42784295

42794296
type RequiredRecursive<T> = {
@@ -4305,6 +4322,9 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
43054322
allowCodeShifting: 'always',
43064323
useMultiLineGhostText: true
43074324
},
4325+
experimental: {
4326+
suppressInlineSuggestions: [],
4327+
},
43084328
};
43094329

43104330
super(
@@ -4336,6 +4356,12 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
43364356
default: defaults.suppressSuggestions,
43374357
description: nls.localize('inlineSuggest.suppressSuggestions', "Controls how inline suggestions interact with the suggest widget. If enabled, the suggest widget is not shown automatically when inline suggestions are available.")
43384358
},
4359+
'editor.inlineSuggest.experimental.suppressInlineSuggestions': {
4360+
type: 'array',
4361+
tags: ['experimental', 'onExp'],
4362+
items: { type: 'string' },
4363+
description: nls.localize('inlineSuggest.suppressInlineSuggestions', "Suppresses inline completions for specified extension IDs.")
4364+
},
43394365
'editor.inlineSuggest.fontFamily': {
43404366
type: 'string',
43414367
default: defaults.fontFamily,
@@ -4389,6 +4415,9 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
43894415
renderSideBySide: stringSet(input.edits?.renderSideBySide, this.defaultValue.edits.renderSideBySide, ['never', 'auto']),
43904416
useMultiLineGhostText: boolean(input.edits?.useMultiLineGhostText, this.defaultValue.edits.useMultiLineGhostText),
43914417
},
4418+
experimental: {
4419+
suppressInlineSuggestions: stringArray(input.experimental?.suppressInlineSuggestions, this.defaultValue.experimental.suppressInlineSuggestions),
4420+
},
43924421
};
43934422
}
43944423
}

src/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsModel.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class InlineCompletionsModel extends Disposable {
7070
private readonly _suggestPreviewEnabled;
7171
private readonly _suggestPreviewMode;
7272
private readonly _inlineSuggestMode;
73+
private readonly _suppressedInlineCompletionGroupIds;
7374
private readonly _inlineEditsEnabled;
7475
private readonly _inlineEditsShowCollapsedEnabled;
7576

@@ -103,6 +104,7 @@ export class InlineCompletionsModel extends Disposable {
103104
this._suggestPreviewEnabled = this._editorObs.getOption(EditorOption.suggest).map(v => v.preview);
104105
this._suggestPreviewMode = this._editorObs.getOption(EditorOption.suggest).map(v => v.previewMode);
105106
this._inlineSuggestMode = this._editorObs.getOption(EditorOption.inlineSuggest).map(v => v.mode);
107+
this._suppressedInlineCompletionGroupIds = this._editorObs.getOption(EditorOption.inlineSuggest).map(v => new Set(v.experimental.suppressInlineSuggestions));
106108
this._inlineEditsEnabled = this._editorObs.getOption(EditorOption.inlineSuggest).map(v => !!v.edits.enabled);
107109
this._inlineEditsShowCollapsedEnabled = this._editorObs.getOption(EditorOption.inlineSuggest).map(s => s.edits.showCollapsed);
108110
this._lastShownInlineCompletionInfo = undefined;
@@ -220,8 +222,10 @@ export class InlineCompletionsModel extends Disposable {
220222
const userJumpedToActiveCompletion = this._jumpedToId.map(jumpedTo => !!jumpedTo && jumpedTo === this._inlineCompletionItems.get()?.inlineEdit?.semanticId);
221223

222224
const providers = changeSummary.provider ? [changeSummary.provider] : this._languageFeaturesService.inlineCompletionsProvider.all(this.textModel);
225+
const suppressedProviderGroupIds = this._suppressedInlineCompletionGroupIds.get();
226+
const availableProviders = providers.filter(provider => !(provider.groupId && suppressedProviderGroupIds.has(provider.groupId)));
223227

224-
return this._source.fetch(providers, cursorPosition, context, itemToPreserve?.identity, changeSummary.shouldDebounce, userJumpedToActiveCompletion, !!changeSummary.provider);
228+
return this._source.fetch(availableProviders, cursorPosition, context, itemToPreserve?.identity, changeSummary.shouldDebounce, userJumpedToActiveCompletion, !!changeSummary.provider);
225229
});
226230
this._inlineCompletionItems = derivedOpts({ owner: this }, reader => {
227231
const c = this._source.inlineCompletions.read(reader);

0 commit comments

Comments
 (0)