Decisive Development
Decisive Development

Reputation: 67

Auto complete creates 'highlighted text' which prevents auto-suggestion

As you can see from this video: https://i.sstatic.net/3nLxr.jpg

When I autocomplete 'class' by pressing 'tab' the text I enter will be 'highlighted'.

You can see, 'tw-grid' is suggested, which should auto-complete as the top suggestion by pressing tab again. However this does not happen, the only way to allow 'tab' to auto complete the top suggestion is to:

  1. arrow key down and hit 'tab'
  2. press 'esc' or 'tab' and move the cursor back to the text and retype.

Any suggestions to fix this weird highlighting behavior, i would really just like to type 'cl' + tab = class=""

'twg' + tab = class="tw-grid" Without this constant leaving and re-entering the class block

Upvotes: 0

Views: 62

Answers (2)

Mark
Mark

Reputation: 180631

Try disabling this setting:

Editor > Suggest: Snippets Prevent Quick Suggestions  // default is enabled

The issue is that when you class it inserts a snippet: class='|' with the cursor at the pipe. So you are still inside a snippet and apparently that is enough to prevent your next typing (twg) to focus any suggestion.

Upvotes: 2

boocs
boocs

Reputation: 599

Ctrl+Space is default keybind for focusSuggestion or...

I had to fix this for my upcoming unreal clangd extension.

export const onDidChangeTextDocument = async (e: vscode.TextDocumentChangeEvent) => {

    const currentActiveEditor = vscode.window.activeTextEditor;
    if(e.contentChanges.length === 0 || e.document !== currentActiveEditor?.document){
        return;
    }
 
    const firstContentChange = e.contentChanges[0];

    if(focusSuggestionDelaySetting !== 0 && e.contentChanges.length === 1 && firstContentChange.text.length === 1){
        await delay(focusSuggestionDelaySetting);  // default 350
        await vscode.commands.executeCommand(VSCODE_CMD_FOCUS_SUGGESTION);  // "focusSuggestion"
    }

Upvotes: 0

Related Questions