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

Completion list is filtered on leading whitespace #66860

Closed
DanTup opened this issue Jan 21, 2019 · 3 comments
Closed

Completion list is filtered on leading whitespace #66860

DanTup opened this issue Jan 21, 2019 · 3 comments
Assignees
Labels
*dev-question VS Code Extension Development Question

Comments

@DanTup
Copy link
Contributor

DanTup commented Jan 21, 2019

Given a language that takes named args with colons:

myFunc(foo: 1);

It seems sensible to set : as a trigger character to open completion. This works fine:

context.subscriptions.push(vscode.languages.registerCompletionItemProvider("markdown", {
    provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext): vscode.CompletionItem[] {
        return [
            new vscode.CompletionItem("test"),
        ];
    }
}, ":"));

screenshot 2019-01-21 at 6 32 47 pm

However, if you type a space (as shown above, to have whitespace between : and the value), the completion list gets filtered and disappears. While it's possible to set <space> as a trigger character, that results in the completion provider being called a lot (for example on every space inside comments) which then need to be filtered out by the extension.

Is it reasonable to ignore leading whitespace when filtering the completion list to simplify things? It seems almost certain that no provider is ever going to return completion items with leading spaces expecting them to be precisely filtered?

@jrieken
Copy link
Member

jrieken commented Jan 21, 2019

You must filterText and sortText then, the simple, label-only, completion doesn't cover this case.

@jrieken jrieken added the *dev-question VS Code Extension Development Question label Jan 21, 2019
@vscodebot
Copy link

vscodebot bot commented Jan 21, 2019

We have a great developer community over on slack where extension authors help each other. This is a great place for you to ask questions and find support.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Jan 21, 2019
@DanTup
Copy link
Contributor Author

DanTup commented Jan 22, 2019

@jrieken Do you mean prefix the filterText for all entries with spaces? I can certainly try this, but it feels a bit weird as a solution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*dev-question VS Code Extension Development Question
Projects
None yet
Development

No branches or pull requests

2 participants