I'm trying to select one of the suggestions IntelliSense suggests me using the Tab key. While using the Enter key works as expected, Tab inserts the suggestion before the text and closes the quote breaking my json. How can I configure Tab to behave the same way as Enter does?
Expected behaviour with Enter:
Wrong behaviour with Tab:
Probably related default options:
"editor.suggest.insertMode": "insert",
"[jsonc]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"editor.tabCompletion": "off",
Looks like Enter follows custom rules for JSON with comments, but Tab does not.
This issue was found to be caused by the IntelliJ IDEA Keybindings extension. And looking under its hood, it's pretty simple why it happens. Look in its package.json file (its extension manifest), and look in the contributes
> keybindings
property. You'll see this:
{
"key": "enter",
"mac": "enter",
"command": "acceptSelectedSuggestion",
"when": "acceptSuggestionOnEnter && suggestWidgetVisible && suggestionMakesTextEdit && textInputFocus",
"intellij": "Choose Lookup Item"
},
{
"key": "tab",
"mac": "tab",
"command": "acceptAlternativeSelectedSuggestion",
"when": "suggestWidgetVisible && textInputFocus",
"intellij": "Choose Lookup Item Replace"
},
See Difference between "acceptSelectedSuggestion" and "acceptAlternativeSelectedSuggestion" in VSCode keybinding config, which explains that:
acceptSelectedSuggestion
causes the text to the right of the caret to be kept after the suggestion is accepted.
acceptAlternativeSelectedSuggestion
causes the text to the right of the caret to be removed after the suggestion is accepted.
Note: If you want to check if an extension is causing a specific behaviour, here's what you can do to troubleshoot: Does the behaviour happen when you reload VS Code with extensions disabled (use the Developer: Reload With Extensions Disabled
command in the command palette)? If not, then do an extension bisect to figure out what extension is causing it.