I have a custom CompletionItemProvider for Monaco editor.
Is it possible to force Monaco show the completion list even if there are no matches?
For example, imagine that I always provide two completion items: abc and def:
a, then abc is shownd, then def is shownz, then nothing is shown at all. Which makes sense by default.
But how can I make both abc and def appear in this case anyway? The use case is that our users might not be aware of using ctrl+space to trigger completion, so we would like to present completion list even if nothing matches so that the users can explore the options and possibly correct themselves.
Your completion provider is called on every time a user types a letter. Let's assume you built a super simple provider that just returns ['abc', 'def'] each time it's called.
In that case you'll get the behavior you observe. Why? Because what triggered the provider is the user typing 'a' or 'd' or 'z' or something. If they type 'a' you'll only see 'abc' and if they type 'd' you'll only see 'def', and you'll get nothing if they type 'z'
If you want you can specify another trigger character, like space, or '.' that will open the entire list.
monaco.languages.registerCompletionItemProvider('javascript', {
triggerCharacters: ['.', ' '],
provideCompletionItems: ...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With