microsoft / microsoft/monaco-editor

Invalid completion items when using dots in completion item label

Open
#2,136 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted suggest typescript
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the playground reproduction and the registerCompletionItemProvider/provideCompletionItems entry points shown in the issue. Trace how a completion with a dotted label and insertText is processed after selection, then verify that typing again does not create an unregistered parameters item. No repository file or test is named in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.