Skip to content

Clarification: default value of CompletionList.isIncomplete? #265

Description

textDocument/completion can return either a CompletionItem[] or a {isIncomplete: boolean; items: CompletionItem[];}. The editor uses the isIncomplete flag to determine whether further typing should recompute the list.

If the LSP server returns just CompletionItem[], will the editor recompute the list or not upon further typing? In other words, what is the default value of isIncomplete?

I randomly found the following bit of VSCode source code in src/vs/editor/standalone/browser/standaloneLanguages.ts, which makes me think the default value of isIncomplete is false (in other words, if the LSP server provides just CompletionItem[], then the language server will NOT ask it to recompute upon further typing). But I don't know who invokes this code nor why nor when, so I'm not sure. I believe it's part of the monaco-editor node package.

let list: CompletionList;
if (Array.isArray(value)) {
  list = {
    items: value,
    isIncomplete: false
  };
} else if (typeof value === 'object' && Array.isArray(value.items)) {
  list = value;
  result.incomplete = list.isIncomplete;
} else if (!value) {
  // undefined and null are valid results
  return undefined;
} else {
  // warn about everything else
  console.warn('INVALID result from completion provider. expected CompletionItem-array or CompletionList but got:', value);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions