Search code examples
visual-studio-codeautocompleteintellisensetabnine

VS Code suggestion widget and inline suggestions conflict


I have had this issue since I started using Tabnine for VS Code. I added inline suggestion mode in VS Code and it conflicts with the suggestion panel.

I want my VS Code to work as follows: When typing stuff, hitting tab autocomplete Tabnine and hitting enter insert first pre-selected item in IntelliSense (suggestion panel).

My current situation: Because the first item in the suggestion panel is not pre-selected, hitting enter will go to the next line, and hitting tab will auto-complete Tabnine inline suggestions. Here is a screenshot of my editor when the first item is not pre-selected.

enter image description here

When hitting arrow down key, it will select the first item, and then hitting enter will insert the first item.

Some of my editor settings:

"editor.inlineSuggest.enabled": true,
"editor.suggestSelection": "first",
"editor.suggest.selectionMode": "never"
 "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.suggestSelection": "recentlyUsed"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.suggestSelection": "recentlyUsed"
  },

Solution

  • I'm guessing you set "editor.suggest.selectionMode": "never" in order to "enable tab for tabnine"? But in doing so you made it so you have to manually use arrow keys to focus a suggestion.

    I'd instead suggest just unbinding tab from accepting a selected suggestion. Ex. like this in keybindings.json:

    {
        "key": "tab",
        "command": "-acceptSelectedSuggestion",
        "when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus"
    },
    

    And then you can remove your "editor.suggest.selectionMode": "never" to let it go back to the default value of "always".


    Actually, another thing you could try is to put "editor.inlineSuggest.suppressSuggestions": true in your settings.json file. The setting's description:

    Controls how inline suggestions interact with the suggest widget. If enabled, the suggest widget is not shown automatically when inline suggestions are available.