Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing ISingleEditOperation in CompletionItem #81

Closed
tpetricek opened this issue Jul 28, 2016 · 4 comments
Closed

Providing ISingleEditOperation in CompletionItem #81

tpetricek opened this issue Jul 28, 2016 · 4 comments
Assignees

Comments

@tpetricek
Copy link

I'm trying to implement CompletionItemProvider.provideCompletionItems and I would like to explicitly specify the edit operation - this is because the language allows identifiers with spaces and so the completion needs to replace text in a range that may include spaces (the default mechanism does not seem to work in this case - it probably searches for the last space and inserts the text there (?)).

However, no matter what I do, I get "No suggestions":

monaco-1

The completion items that I'm returning look like this:

monaco-2

When I do not set textEdit, the completion list shows possible completions just fine (but it inserts text badly when the completion involves spaces). In the screenshot, I set filterText and insertText, but when I do not do that, the result is the same.

Am I doing something obviously wrong here? Is there a working sample of using textEdit somewhere?

PS: Also, is this the right place to ask questions like this, or do you have another recommended channel?

@tpetricek
Copy link
Author

(I'm aware that the above might not quite provide enough information about the issue - I'm hoping that Monaco experts might immediately spot what I'm doing wrong - but if no, let me know and I can try to create a simple shareable repro.)

@jrieken
Copy link
Member

jrieken commented Aug 15, 2016

The text edit you return is a single edit operation - so you are on the right path. By default, when you don't give a text edit, we basically build an edit from the current word range until position and the label of the suggestion. Then, the editor compares the text that got selected by the edit and compares that against the label or filterText. In your case it like this: [1,9, 1,10] == '.d' which is compared against data etc. Since none match you see an empty list. The rule is that your filterText or label matches at least what you select for replacing and what you will insert

@jrieken jrieken closed this as completed Aug 15, 2016
@tpetricek
Copy link
Author

Well, this is is embarrassing. So it was all just off-by-one error. Works great now.

monaco

If you want to see it in action, click on "source" in any of the visualizations here: http://rio2016.thegamma.net 👍

@alexdima
Copy link
Member

@tpetricek I saw the website a couple of days ago! Very cool! 👍

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants