Microsoft/monaco-editor

Invalid completion items when using dots in completion item label

Open

#2,136 opened on Sep 17, 2020

View on GitHub
 (3 comments) (0 reactions) (0 assignees)JavaScript (1,283 forks)batch import
bughelp wantedsuggesttypescript

Repository metrics

Stars
 (14,836 stars)
PR merge metrics
 (Avg merge 6h 26m) (15 merged PRs in 30d)

Description

monaco-editor version: 0.20.0 Browser: Chrome OS: Windows Playground code that reproduces the issue:

function getSuggestions(range) {
    return [
        {
            label: 'parameters.In1',
            kind: monaco.languages.CompletionItemKind.Field,
            insertText: 'parameters.In1',
            insertTextRules: null,
            range: range
        }
    ];
}


monaco.languages.registerCompletionItemProvider('javascript', {
    provideCompletionItems: function(model, position) {
        return {
            suggestions: getSuggestions(null)
        };
    }
});

monaco.editor.create(document.getElementById("container"), {
    language: "javascript"
});

I was only able to reproduce this when registering a completion item provider which return completion items with dots in the label/insertText.

Repro steps:

  1. Execute the code above
  2. Type param and choose the option parameters.In1
  3. Type again type Result: The completion menu shows an option "parameters" which was not returned by my provider neither exists in the Javascript language.

See the gif below: issue-autocomplete2

Contributor guide