Merge pull request #183954 from microsoft/joh/overwhelming-tuna

joh/overwhelming tuna
This commit is contained in:
Johannes Rieken 2023-05-31 16:40:21 +02:00 committed by GitHub
commit 070168f694
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View file

@ -4134,6 +4134,10 @@ export interface ISuggestOptions {
* Enable graceful matching. Defaults to true.
*/
filterGraceful?: boolean;
/**
* Prevent quick suggestions when a snippet is active. Defaults to true.
*/
snippetsPreventQuickSuggestions?: boolean;
/**
* Favors words that appear close to the cursor.
*/
@ -4295,6 +4299,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
const defaults: InternalSuggestOptions = {
insertMode: 'insert',
filterGraceful: true,
snippetsPreventQuickSuggestions: false,
localityBonus: false,
shareSuggestSelections: false,
selectionMode: 'always',
@ -4373,6 +4378,11 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
default: defaults.selectionMode,
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`.")
},
'editor.suggest.snippetsPreventQuickSuggestions': {
type: 'boolean',
default: defaults.snippetsPreventQuickSuggestions,
description: nls.localize('suggest.snippetsPreventQuickSuggestions', "Controls whether an active snippet prevents quick suggestions.")
},
'editor.suggest.showIcons': {
type: 'boolean',
default: defaults.showIcons,
@ -4563,6 +4573,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
return {
insertMode: stringSet(input.insertMode, this.defaultValue.insertMode, ['insert', 'replace']),
filterGraceful: boolean(input.filterGraceful, this.defaultValue.filterGraceful),
snippetsPreventQuickSuggestions: boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
localityBonus: boolean(input.localityBonus, this.defaultValue.localityBonus),
shareSuggestSelections: boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
selectionMode: stringSet(input.selectionMode, this.defaultValue.selectionMode, ['always', 'never', 'whenQuickSuggestion', 'whenTriggerCharacter']),

View file

@ -246,9 +246,8 @@ export class SuggestController implements IEditorContribution {
let noFocus = false;
if (e.triggerOptions.auto) {
// don't "focus" item when configured to do so or when in snippet mode (and configured to do so)
// don't "focus" item when configured to do
const options = this.editor.getOption(EditorOption.suggest);
if (options.selectionMode === 'never' || options.selectionMode === 'always') {
// simple: always or never
noFocus = options.selectionMode === 'never';
@ -777,7 +776,7 @@ registerEditorCommand(new SuggestCommand({
kbOpts: [{
// normal tab
primary: KeyCode.Tab,
kbExpr: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus, SnippetController2.InSnippetMode.toNegated()),
kbExpr: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus),
weight,
}, {
// accept on enter has special rules
@ -811,7 +810,7 @@ registerEditorCommand(new SuggestCommand({
precondition: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus, SuggestContext.HasFocusedSuggestion),
kbOpts: {
weight: weight,
kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, SnippetController2.InSnippetMode.toNegated()),
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.Shift | KeyCode.Enter,
secondary: [KeyMod.Shift | KeyCode.Tab],
},

View file

@ -35,6 +35,7 @@ suite('CompletionModel', function () {
const defaultOptions = <InternalSuggestOptions>{
insertMode: 'insert',
snippetsPreventQuickSuggestions: true,
filterGraceful: true,
localityBonus: false,
shareSuggestSelections: false,

4
src/vs/monaco.d.ts vendored
View file

@ -4543,6 +4543,10 @@ declare namespace monaco.editor {
* Enable graceful matching. Defaults to true.
*/
filterGraceful?: boolean;
/**
* Prevent quick suggestions when a snippet is active. Defaults to true.
*/
snippetsPreventQuickSuggestions?: boolean;
/**
* Favors words that appear close to the cursor.
*/