Skip to content

CompletionEntry.insertText #20730

@mjbvz

Description

@mjbvz

Problem
#19433 requests the ability to have completion items for symbols that require bracket access, such as obj['space prop']. This is currently implemented using additionalTextEdits, which have their own complications on the VS Code side (see microsoft/vscode#39893).

As a simplified approach that better matches the VS Code API, we would instead like to introduce an insertText property on for CompletionEntry

Proposal
Add a new insertText property on CompletionEntry:

interface CompletionEntry {
    name: string
    ...

    // Text to be inserted instead of `name`.
    insertText?: string
}

When used alongside the replacementSpan property, this would allow us to implement #19433

To keep this change non-breaking, I propose we add a new flag to CompletionsRequestArgs to enable these symbols being returned:

    interface CompletionsRequestArgs extends FileLocationRequestArgs {
      ...
      includeInsertTextCompletions?: boolean;
    }

Completions that require insertText would only be returned if includeInsertTextCompletions is set to true.

includeInsertTextCompletions seems like a poor name. We could be more specific to #19433 and call it includeBracetCompletions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: APIRelates to the public API for TypeScriptFixedA PR has been merged for this issueSuggestionAn idea for TypeScriptVS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions