Skip to content

Commit 44069a3

Browse files
authored
Introduces editor.inlineSuggest.suppressSuggestions, deprecates .allowQuickSuggestions and .allowSuggestOnTriggerCharacters (microsoft#178208)
1 parent fabb574 commit 44069a3

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3805,6 +3805,8 @@ export interface IInlineSuggestOptions {
38053805
mode?: 'prefix' | 'subword' | 'subwordSmart';
38063806

38073807
showToolbar?: 'always' | 'onHover';
3808+
3809+
suppressSuggestions?: boolean;
38083810
}
38093811

38103812
/**
@@ -3821,6 +3823,7 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
38213823
enabled: true,
38223824
mode: 'subwordSmart',
38233825
showToolbar: 'onHover',
3826+
suppressSuggestions: false,
38243827
};
38253828

38263829
super(
@@ -3841,6 +3844,11 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
38413844
],
38423845
description: nls.localize('inlineSuggest.showToolbar', "Controls when to show the inline suggestion toolbar."),
38433846
},
3847+
'editor.inlineSuggest.suppressSuggestions': {
3848+
type: 'boolean',
3849+
default: defaults.suppressSuggestions,
3850+
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.")
3851+
},
38443852
}
38453853
);
38463854
}
@@ -3854,6 +3862,7 @@ class InlineEditorSuggest extends BaseEditorOption<EditorOption.inlineSuggest, I
38543862
enabled: boolean(input.enabled, this.defaultValue.enabled),
38553863
mode: stringSet(input.mode, this.defaultValue.mode, ['prefix', 'subword', 'subwordSmart']),
38563864
showToolbar: stringSet(input.showToolbar, this.defaultValue.showToolbar, ['always', 'onHover']),
3865+
suppressSuggestions: boolean(input.suppressSuggestions, this.defaultValue.suppressSuggestions),
38573866
};
38583867
}
38593868
}

src/vs/editor/contrib/suggest/browser/suggestModel.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,13 @@ export const enum State {
101101
Auto = 2
102102
}
103103

104-
function isSuggestPreviewEnabled(editor: ICodeEditor): boolean {
105-
return editor.getOption(EditorOption.suggest).preview;
106-
}
107-
108104
function canShowQuickSuggest(editor: ICodeEditor, contextKeyService: IContextKeyService, configurationService: IConfigurationService): boolean {
109105
if (!Boolean(contextKeyService.getContextKeyValue('inlineSuggestionVisible'))) {
110106
// Allow if there is no inline suggestion.
111107
return true;
112108
}
113109

114-
const allowQuickSuggestions = configurationService.getValue('editor.inlineSuggest.allowQuickSuggestions', { overrideIdentifier: editor.getModel()?.getLanguageId(), resource: editor.getModel()?.uri });
115-
if (allowQuickSuggestions !== undefined) {
116-
// Use setting if available.
117-
return Boolean(allowQuickSuggestions);
118-
}
119-
120-
// Don't allow if inline suggestions are visible and no suggest preview is configured.
121-
// TODO disabled for copilot
122-
return false && isSuggestPreviewEnabled(editor);
110+
return !editor.getOption(EditorOption.inlineSuggest).suppressSuggestions;
123111
}
124112

125113
function canShowSuggestOnTriggerCharacters(editor: ICodeEditor, contextKeyService: IContextKeyService, configurationService: IConfigurationService): boolean {
@@ -128,12 +116,7 @@ function canShowSuggestOnTriggerCharacters(editor: ICodeEditor, contextKeyServic
128116
return true;
129117
}
130118

131-
const allowQuickSuggestions = configurationService.getValue('editor.inlineSuggest.allowSuggestOnTriggerCharacters', { overrideIdentifier: editor.getModel()?.getLanguageId(), resource: editor.getModel()?.uri });
132-
if (allowQuickSuggestions !== undefined) {
133-
// Use setting if available.
134-
return Boolean(allowQuickSuggestions);
135-
}
136-
return true;
119+
return !editor.getOption(EditorOption.inlineSuggest).suppressSuggestions;
137120
}
138121

139122
export class SuggestModel implements IDisposable {

src/vs/monaco.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,6 +4351,7 @@ declare namespace monaco.editor {
43514351
*/
43524352
mode?: 'prefix' | 'subword' | 'subwordSmart';
43534353
showToolbar?: 'always' | 'onHover';
4354+
suppressSuggestions?: boolean;
43544355
}
43554356

43564357
export interface IBracketPairColorizationOptions {

0 commit comments

Comments
 (0)