microsoft / microsoft/monaco-editor
[Feature Request] Can we have a predicate to decide if a completion popup should be displayed?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Context
- This issue is not a bug report. (please use a different template for reporting a bug)
- This issue is not a duplicate of an existing issue. (please use the search to find existing issues)
Description
When we develop our own code completion implementing the CompletionItemProvider interface we are bound to a set of trigger characters that make the popup to be shown. This in some cases is not really convenient as the popup shows in the wrong context. For example I'm interested in displaying autocompletion in case of identifier usage and not to show it when declaring one. While searching the internet I was able to find some "dirty" suggestions like sending events. See #1764.
Anyway, can we have a predicate function instead or in addition to the triggerCharacters array? It could look like this:
triggerPopup(model, position, context): boolean
Then we can have an access to model to do some parsing and make a decision based on last token. We have a context to find out which event triggered the function and we know a cursor position. Probably, a delay to call this predicate should be set in the editor configuration, so it won't be called too often.
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
No response
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 by reviewing the CompletionItemProvider interface and the existing triggerCharacters behavior described in the issue. Determine how a predicate using model, position, and context would control popup display, and consider the proposed delay configuration; done means completion providers can suppress or allow the popup based on that predicate without relying only on trigger characters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100