How to provide a completion item that has a 'low priority' in a VS CODE extension?

Viewed 527

I have a VS Code extension that provides completion items for C#. I would like to make it so they will only show up in the bottom of the completion options, after all other options were exhausted (rather than just lexicographically).

As far as I know the API provides no way of doing this (although i'd like to be proven wrong). So one way I've thought of hacking it in is by prefixing the vscode.CompletionsItem's sortText with ~. The problem is for some reason it only works when comparing my CompletionItems with other CompletionItems that have explicitly specified the value of the sortText field.

let completion = {
        label :"Hello World!",
        sortText:~Hello World!"
    }
// That works fine with this one for example:
let explicitCompletion= {
        label :"World!",
        sortText:"World!"
    }
// But will appear before this one, despite having appended '~'
let implicitCompletion= {
        label :"World!",
    }

All completions for the C# extension have an implicit sortText so it doesn't work.

Another way of doing it but is imperfect is by keeping the insertText and filterText but prefixing the label.

let completion = {
        label :"~Hello World!",
        insertText:Hello World!",
        filterText:Hello World!",
    }

The problem is that now there is an annoying ~ that shows at the start of the completion.

So finally, how can I make it so my completions will appear after the default C# completions without having a weird prefix showing at the start. (In the example, the "Hello World!" completion will appear after "World!", without changing the "World!" completion.)

0 Answers
Related