I'm trying to write an extension for VSCode with an auto-completion service, using the OmniSharp.Extensions.LanguageServer
nuget package. I want to insert code snippets when the user selects a completion item.
It works if I set the Label
property of the completion items to the text of my snippets. However, my labels now look ugly in the completion list because they have to contain linebreaks and tabs. So I was looking for another solution.
According to the Vscode CompletionItem
class documentation, it looks like I need to use the property InsertText
instead of or in addition to Label
:
A string or snippet that should be inserted in a document when selecting this completion. When falsy, the
label
is used.
Problem:
In my case, even if I set the InsertText
to something that is not falsy, VSCode will still insert the value of the Label
property.
What could cause this behavior? Is this a bug in Omnisharp, or is there another configuration I'm not aware of that I have to set to force VSCode to insert the value of the InsertText
instead of the value of the Label
?
I figured it out: I also was using the
ComplitionItem.TextEdit
property. It caused the setComplitionItem.InsertText
property to be ignored. According to the documentation,ComplitionItem.TextEdit
is