Skip to content

Completion list is filtered on leading whitespace #66860

Closed

Description

@DanTup

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?

Activity

  1. jrieken commented on Jan 21, 2019

    @jrieken
    Contributor

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

  2. vscodebot commented on Jan 21, 2019

    @vscodebot

    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!

  3. DanTup commented on Jan 22, 2019

    @DanTup
    ContributorAuthor

    Johannes Rieken (@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.

  4. locked and limited conversation to collaborators on Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*dev-questionVS Code Extension Development Question

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions