• Public
  • Public/Protected
  • All

Class CompletionItem

A completion item represents a text snippet that is proposed to complete text that is being typed.

It is sufficient to create a completion item from just a label. In that case the completion item will replace the word until the cursor with the given label or insertText. Otherwise the given edit is used.

When selecting a completion item in the editor its defined or synthesized text edit will be applied to all cursors/selections whereas additionalTextEdits will be applied as provided.






  • CompletionItem






label: string | CompletionItemLabel

The label of this completion item. By default this is also the text that is inserted when selecting this completion.

Optional kind

The kind of this completion item. Based on the kind an icon is chosen by the editor.

Optional tags

tags: readonly Deprecated[]

Tags for this completion item.

Optional detail

detail: string

A human-readable string with additional information about this item, like type or symbol information.

Optional documentation

documentation: string | MarkdownString

A human-readable string that represents a doc-comment.

Optional sortText

sortText: string

A string that should be used when comparing this item with other items. When falsy the label is used.

Note that sortText is only used for the initial ordering of completion items. When having a leading word (prefix) ordering is based on how well completions match that prefix and the initial ordering is only used when completions match equally well. The prefix is defined by the range-property and can therefore be different for each completion.

Optional filterText

filterText: string

A string that should be used when filtering a set of completion items. When falsy the label is used.

Note that the filter text is matched against the leading word (prefix) which is defined by the range-property.

Optional preselect

preselect: boolean

Select this item when showing. Note that only one completion item can be selected and that the editor decides which item that is. The rule is that the first item of those that match best is selected.

Optional insertText

insertText: string | SnippetString

A string or snippet that should be inserted in a document when selecting this completion. When falsy the label is used.

Optional range

range: Range | { inserting: Range; replacing: Range }

A range or a insert and replace range selecting the text that should be replaced by this completion item.

When omitted, the range of the current word is used as replace-range and as insert-range the start of the current word to the current position is used.

Note 1: A range must be a single line and it must contain the position at which completion has been requested. Note 2: A insert range must be a prefix of a replace range, that means it must be contained and starting at the same position.

Optional commitCharacters

commitCharacters: string[]

An optional set of characters that when pressed while this completion is active will accept it first and then type that character. Note that all commit characters should have length=1 and that superfluous characters will be ignored.

Optional keepWhitespace

keepWhitespace: boolean

Keep whitespace of the insertText as is. By default, the editor adjusts leading whitespace of new lines so that they match the indentation of the line for which the item is accepted - setting this to true will prevent that.

Optional textEdit

textEdit: TextEdit

Use CompletionItem.insertText and CompletionItem.range instead.

An edit which is applied to a document when selecting this completion. When an edit is provided the value of insertText is ignored.

The Range of the edit must be single-line and on the same line completions were requested at.

Optional additionalTextEdits

additionalTextEdits: TextEdit[]

An optional array of additional text edits that are applied when selecting this completion. Edits must not overlap with the main edit nor with themselves.

Optional command

command: Command

An optional Command that is executed after inserting this completion. Note that additional modifications to the current document should be described with the additionalTextEdits-property.

Generated by TypeDoc. Maintained by 洛竹