Skip to content

[completion] CompletionList#isIncomplete ignored on empty or fully filtered items #13735

Closed

Description

  • VSCode Version: 1.6.1

When a CompletionList returns an empty array of items but has set isIncomplete: true, the content proposal provider is not asked again on further typing.

I think it is because
https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/suggest/common/completionModel.ts#L167
is not reached if no item exists or all items are filtered.

Is this intentional?

It can be reproduced easily with monaco's playground:
https://microsoft.github.io/monaco-editor/playground.html#extending-language-services-completion-provider-example

Paste the following snippet into it:

function createDependencyProposals(contents) {
    if (contents.length%4 === 0) {
        return {
            isIncomplete: true,
            items: []
        }
    }
    return {
        isIncomplete: true,
        items: [
            {
                label: contents + "!!",
                kind: monaco.languages.CompletionItemKind.Function,
                documentation: contents + "!!",
                insertText: contents + "!!"
            }
        ]
    };
}


monaco.languages.registerCompletionItemProvider('json', {
    provideCompletionItems: function(model, position) {
        // find out if we are completing a property in the 'dependencies' object.
        var textUntilPosition = model.getValueInRange({startLineNumber: 1, startColumn: 1, endLineNumber: position.lineNumber, endColumn: position.column});
        return createDependencyProposals(textUntilPosition);
    }
});

monaco.editor.create(document.getElementById("container"), {
    value: "",
    language: "json"
});

Activity

  1. jrieken commented on Oct 14, 2016

    @jrieken
    Contributor

    An empty result is considered no result and doesn't even make it into the view model - so, yes that is that is on purpose.

    Incomplete but not empty lists will trigger the ask-again-on-type-logic if the very first time the result-set wasn't filtered to empty. I think that is fair because completions should always match the current line value before the position.

  2. svenefftinge commented on Dec 6, 2016

    @svenefftinge
    Author

    The problem is that if I use the isIncomplete mode, to return different results based on the offset and prefix and there is a position that returns nothing, I don't get retriggered in that same context anymore. E.g. I have a prefix of i where completion returns two elements, then I type s which retriggers, because previous was set toisIncomplete, now I type another character, retriggering happens again and the result is empty. If I now press backspace I no longer get proposals, because VSCode has forgotten about the 'isIncomplete' flag but treats it as the same context.

  3. added
    suggest
    under-discussion
    on Apr 21, 2017
  4. added
    bug
    and removed
    under-discussion
    on Sep 11, 2018
  5. added
    *out-of-scope
    on Sep 20, 2018
  6. vscodebot commented on Sep 20, 2018

    @vscodebot

    This iteration we focus on issue grooming. This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

    If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

    Thanks for your understanding and happy coding!

  7. added a commit that references this issue on Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*out-of-scopebugsuggest

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions