Skip to content

Commit 070168f

Browse files
authored
Merge pull request microsoft#183954 from microsoft/joh/overwhelming-tuna
joh/overwhelming tuna
2 parents 5c01360 + 517370b commit 070168f

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4134,6 +4134,10 @@ export interface ISuggestOptions {
41344134
* Enable graceful matching. Defaults to true.
41354135
*/
41364136
filterGraceful?: boolean;
4137+
/**
4138+
* Prevent quick suggestions when a snippet is active. Defaults to true.
4139+
*/
4140+
snippetsPreventQuickSuggestions?: boolean;
41374141
/**
41384142
* Favors words that appear close to the cursor.
41394143
*/
@@ -4295,6 +4299,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
42954299
const defaults: InternalSuggestOptions = {
42964300
insertMode: 'insert',
42974301
filterGraceful: true,
4302+
snippetsPreventQuickSuggestions: false,
42984303
localityBonus: false,
42994304
shareSuggestSelections: false,
43004305
selectionMode: 'always',
@@ -4373,6 +4378,11 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
43734378
default: defaults.selectionMode,
43744379
markdownDescription: nls.localize('suggest.selectionMode', "Controls whether a suggestion is selected when the widget shows. Note that this only applies to automatically triggered suggestions (`#editor.quickSuggestions#` and `#editor.suggestOnTriggerCharacters#`) and that a suggestion is always selected when explicitly invoked, e.g via `Ctrl+Space`.")
43754380
},
4381+
'editor.suggest.snippetsPreventQuickSuggestions': {
4382+
type: 'boolean',
4383+
default: defaults.snippetsPreventQuickSuggestions,
4384+
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Controls whether an active snippet prevents quick suggestions.")
4385+
},
43764386
'editor.suggest.showIcons': {
43774387
type: 'boolean',
43784388
default: defaults.showIcons,
@@ -4563,6 +4573,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
45634573
return {
45644574
insertMode: stringSet(input.insertMode, this.defaultValue.insertMode, ['insert', 'replace']),
45654575
filterGraceful: boolean(input.filterGraceful, this.defaultValue.filterGraceful),
4576+
snippetsPreventQuickSuggestions: boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
45664577
localityBonus: boolean(input.localityBonus, this.defaultValue.localityBonus),
45674578
shareSuggestSelections: boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
45684579
selectionMode: stringSet(input.selectionMode, this.defaultValue.selectionMode, ['always', 'never', 'whenQuickSuggestion', 'whenTriggerCharacter']),

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,8 @@ export class SuggestController implements IEditorContribution {
246246

247247
let noFocus = false;
248248
if (e.triggerOptions.auto) {
249-
// don't "focus" item when configured to do so or when in snippet mode (and configured to do so)
249+
// don't "focus" item when configured to do
250250
const options = this.editor.getOption(EditorOption.suggest);
251-
252251
if (options.selectionMode === 'never' || options.selectionMode === 'always') {
253252
// simple: always or never
254253
noFocus = options.selectionMode === 'never';
@@ -777,7 +776,7 @@ registerEditorCommand(new SuggestCommand({
777776
kbOpts: [{
778777
// normal tab
779778
primary: KeyCode.Tab,
780-
kbExpr: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus, SnippetController2.InSnippetMode.toNegated()),
779+
kbExpr: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus),
781780
weight,
782781
}, {
783782
// accept on enter has special rules
@@ -811,7 +810,7 @@ registerEditorCommand(new SuggestCommand({
811810
precondition: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus, SuggestContext.HasFocusedSuggestion),
812811
kbOpts: {
813812
weight: weight,
814-
kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, SnippetController2.InSnippetMode.toNegated()),
813+
kbExpr: EditorContextKeys.textInputFocus,
815814
primary: KeyMod.Shift | KeyCode.Enter,
816815
secondary: [KeyMod.Shift | KeyCode.Tab],
817816
},

src/vs/editor/contrib/suggest/test/browser/completionModel.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ suite('CompletionModel', function () {
3535

3636
const defaultOptions = <InternalSuggestOptions>{
3737
insertMode: 'insert',
38+
snippetsPreventQuickSuggestions: true,
3839
filterGraceful: true,
3940
localityBonus: false,
4041
shareSuggestSelections: false,

src/vs/monaco.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,6 +4543,10 @@ declare namespace monaco.editor {
45434543
* Enable graceful matching. Defaults to true.
45444544
*/
45454545
filterGraceful?: boolean;
4546+
/**
4547+
* Prevent quick suggestions when a snippet is active. Defaults to true.
4548+
*/
4549+
snippetsPreventQuickSuggestions?: boolean;
45464550
/**
45474551
* Favors words that appear close to the cursor.
45484552
*/

0 commit comments

Comments
 (0)