microsoft / microsoft/monaco-editor
[Bug] Down arrow is not working if suggestion dropdown inside snippet only have one item
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
function createSuggestions (range) {
const kind = monaco.languages.CompletionItemKind.Snippet;
const insertTextRules = monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
return [
{
label: 'line',
kind,
detail: 'Line',
insertText: 'Line 1: $1\nLine2: $2\n',
insertTextRules,
range,
},
{
label: 'while-do',
kind,
detail: 'Inline note',
insertText: 'note: \'${1:}\'',
insertTextRules,
range,
},
{
label: 'for-each',
kind,
detail: 'For each loop',
insertText: 'Some snippet text',
insertTextRules,
range,
},
{
label: 'for-in',
kind,
detail: 'For in loop',
insertText: 'Some snippet text',
insertTextRules,
range,
},
];
}
monaco.languages.registerCompletionItemProvider("json", {
provideCompletionItems: function (model, position) {
var word = model.getWordUntilPosition(position);
var range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn,
};
return {
suggestions: createSuggestions(range),
};
},
});
monaco.editor.create(document.getElementById("container"), {
value: '',
language: "json",
});
Reproduction Steps
- Type
li - Press
Tab - Type
wh - Press
Down arrow

- The cursor goes to the next line

Actual (Problematic) Behavior
When the suggestion dropdown inside a snippet's tabstop only has 1 item, pressing Down arrow will go to next line instead of selecting that item
Expected Behavior
Press Down arrow should select the suggestion item when it has only 1 item.
Additional Context
If the suggestion dropdown has more than 1 item, it can be selected using Up/Down arrow. For example:
- Type
li - Press
Tab - Type
fo - Press
Down arrow
Result:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Monaco Editor Playground and the provided TypeScript completion-provider snippet; reproduce the issue by entering the single-item suggestion inside a snippet tabstop and pressing Down. Trace the completion and snippet interaction, then verify that Down selects the sole suggestion instead of moving to the next line, including the contrasting multi-item case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100