mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
When snippet mode is active, make Tab
not accept suggestion but advance placeholder
Also remove the dreaded `snippetsPreventQuickSuggestions`which prevents suggestions inside snippets. Clear up the confusion about showing but not focusing suggest (#17338) when inside a snippet. resolves/avoids https://github.com/microsoft/vscode/issues/173387
This commit is contained in:
parent
5474fca23c
commit
50a80cdb61
|
@ -4117,10 +4117,6 @@ 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.
|
||||
*/
|
||||
|
@ -4282,7 +4278,6 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, ISuggestOptio
|
|||
const defaults: InternalSuggestOptions = {
|
||||
insertMode: 'insert',
|
||||
filterGraceful: true,
|
||||
snippetsPreventQuickSuggestions: true,
|
||||
localityBonus: false,
|
||||
shareSuggestSelections: false,
|
||||
selectionMode: 'always',
|
||||
|
@ -4361,11 +4356,6 @@ 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,
|
||||
|
@ -4556,7 +4546,6 @@ 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']),
|
||||
|
|
|
@ -249,11 +249,7 @@ export class SuggestController implements IEditorContribution {
|
|||
// don't "focus" item when configured to do so or when in snippet mode (and configured to do so)
|
||||
const options = this.editor.getOption(EditorOption.suggest);
|
||||
|
||||
if (options.snippetsPreventQuickSuggestions && SnippetController2.get(this.editor)?.isInSnippet()) {
|
||||
// SPECIAL: in snippet mode, we never focus unless the user wants to
|
||||
noFocus = true;
|
||||
|
||||
} else if (options.selectionMode === 'never' || options.selectionMode === 'always') {
|
||||
if (options.selectionMode === 'never' || options.selectionMode === 'always') {
|
||||
// simple: always or never
|
||||
noFocus = options.selectionMode === 'never';
|
||||
|
||||
|
@ -775,7 +771,7 @@ registerEditorCommand(new SuggestCommand({
|
|||
kbOpts: [{
|
||||
// normal tab
|
||||
primary: KeyCode.Tab,
|
||||
kbExpr: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus),
|
||||
kbExpr: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus, SnippetController2.InSnippetMode.toNegated()),
|
||||
weight,
|
||||
}, {
|
||||
// accept on enter has special rules
|
||||
|
@ -809,7 +805,7 @@ registerEditorCommand(new SuggestCommand({
|
|||
precondition: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus, SuggestContext.HasFocusedSuggestion),
|
||||
kbOpts: {
|
||||
weight: weight,
|
||||
kbExpr: EditorContextKeys.textInputFocus,
|
||||
kbExpr: ContextKeyExpr.and(EditorContextKeys.textInputFocus, SnippetController2.InSnippetMode.toNegated()),
|
||||
primary: KeyMod.Shift | KeyCode.Enter,
|
||||
secondary: [KeyMod.Shift | KeyCode.Tab],
|
||||
},
|
||||
|
|
|
@ -35,7 +35,6 @@ suite('CompletionModel', function () {
|
|||
|
||||
const defaultOptions = <InternalSuggestOptions>{
|
||||
insertMode: 'insert',
|
||||
snippetsPreventQuickSuggestions: true,
|
||||
filterGraceful: true,
|
||||
localityBonus: false,
|
||||
shareSuggestSelections: false,
|
||||
|
|
4
src/vs/monaco.d.ts
vendored
4
src/vs/monaco.d.ts
vendored
|
@ -4510,10 +4510,6 @@ 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.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue