merge CompletionItemLabel into CompletionItem#label, https://github.com/microsoft/vscode/issues/39441
This commit is contained in:
parent
96e6d1c933
commit
24f9000e97
29
src/vs/vscode.d.ts
vendored
29
src/vs/vscode.d.ts
vendored
|
@ -3975,6 +3975,31 @@ declare module 'vscode' {
|
||||||
readonly retriggerCharacters: readonly string[];
|
readonly retriggerCharacters: readonly string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a structured label for completion items.
|
||||||
|
*/
|
||||||
|
export interface CompletionItemLabel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The label of this completion item. By default
|
||||||
|
* this is also the text that is inserted when selecting
|
||||||
|
* this completion.
|
||||||
|
*/
|
||||||
|
label: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional string which is rendered less prominent and directly after {@link CompletionItemLabel.label name},
|
||||||
|
* without any spacing. Should be used for function signatures or type annotations.
|
||||||
|
*/
|
||||||
|
detail?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional string which is rendered less prominent and after {@link CompletionItemLabel.detail}. Should be used
|
||||||
|
* for fully qualified names or file path.
|
||||||
|
*/
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completion item kinds.
|
* Completion item kinds.
|
||||||
*/
|
*/
|
||||||
|
@ -4041,7 +4066,7 @@ declare module 'vscode' {
|
||||||
* this is also the text that is inserted when selecting
|
* this is also the text that is inserted when selecting
|
||||||
* this completion.
|
* this completion.
|
||||||
*/
|
*/
|
||||||
label: string;
|
label: string | CompletionItemLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The kind of this completion item. Based on the kind
|
* The kind of this completion item. Based on the kind
|
||||||
|
@ -4165,7 +4190,7 @@ declare module 'vscode' {
|
||||||
* @param label The label of the completion.
|
* @param label The label of the completion.
|
||||||
* @param kind The {@link CompletionItemKind kind} of the completion.
|
* @param kind The {@link CompletionItemKind kind} of the completion.
|
||||||
*/
|
*/
|
||||||
constructor(label: string, kind?: CompletionItemKind);
|
constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
32
src/vs/vscode.proposed.d.ts
vendored
32
src/vs/vscode.proposed.d.ts
vendored
|
@ -1396,38 +1396,6 @@ declare module 'vscode' {
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region https://github.com/microsoft/vscode/issues/39441
|
|
||||||
|
|
||||||
export interface CompletionItem {
|
|
||||||
/**
|
|
||||||
* Will be merged into CompletionItem#label
|
|
||||||
*/
|
|
||||||
label2?: CompletionItemLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CompletionItemLabel {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The label of this completion item. By default
|
|
||||||
* this is also the text that is inserted when selecting
|
|
||||||
* this completion.
|
|
||||||
*/
|
|
||||||
label: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A string which is rendered less prominent and directly after {@link CompletionItemLabel.label name}
|
|
||||||
* without any spacing. Should be used for function signatures or type annotations.
|
|
||||||
*/
|
|
||||||
detail?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The fully qualified name, like package name or file path. Rendered after `detail`.
|
|
||||||
*/
|
|
||||||
description?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
//#endregion
|
|
||||||
|
|
||||||
//#region @https://github.com/microsoft/vscode/issues/123601, notebook messaging
|
//#region @https://github.com/microsoft/vscode/issues/123601, notebook messaging
|
||||||
|
|
||||||
export interface NotebookRendererMessage<T> {
|
export interface NotebookRendererMessage<T> {
|
||||||
|
|
|
@ -443,8 +443,10 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||||
|
|
||||||
private static _inflateSuggestDto(defaultRange: IRange | { insert: IRange, replace: IRange }, data: ISuggestDataDto): modes.CompletionItem {
|
private static _inflateSuggestDto(defaultRange: IRange | { insert: IRange, replace: IRange }, data: ISuggestDataDto): modes.CompletionItem {
|
||||||
|
|
||||||
|
const label = data[ISuggestDataDtoField.label];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label: data[ISuggestDataDtoField.label2] ?? data[ISuggestDataDtoField.label],
|
label,
|
||||||
kind: data[ISuggestDataDtoField.kind] ?? modes.CompletionItemKind.Property,
|
kind: data[ISuggestDataDtoField.kind] ?? modes.CompletionItemKind.Property,
|
||||||
tags: data[ISuggestDataDtoField.kindModifier],
|
tags: data[ISuggestDataDtoField.kindModifier],
|
||||||
detail: data[ISuggestDataDtoField.detail],
|
detail: data[ISuggestDataDtoField.detail],
|
||||||
|
@ -452,7 +454,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||||
sortText: data[ISuggestDataDtoField.sortText],
|
sortText: data[ISuggestDataDtoField.sortText],
|
||||||
filterText: data[ISuggestDataDtoField.filterText],
|
filterText: data[ISuggestDataDtoField.filterText],
|
||||||
preselect: data[ISuggestDataDtoField.preselect],
|
preselect: data[ISuggestDataDtoField.preselect],
|
||||||
insertText: typeof data.h === 'undefined' ? data[ISuggestDataDtoField.label] : data.h,
|
insertText: data[ISuggestDataDtoField.insertText] ?? (typeof label === 'string' ? label : label.label),
|
||||||
range: data[ISuggestDataDtoField.range] ?? defaultRange,
|
range: data[ISuggestDataDtoField.range] ?? defaultRange,
|
||||||
insertTextRules: data[ISuggestDataDtoField.insertTextRules],
|
insertTextRules: data[ISuggestDataDtoField.insertTextRules],
|
||||||
commitCharacters: data[ISuggestDataDtoField.commitCharacters],
|
commitCharacters: data[ISuggestDataDtoField.commitCharacters],
|
||||||
|
|
|
@ -1392,14 +1392,10 @@ export const enum ISuggestDataDtoField {
|
||||||
additionalTextEdits = 'l',
|
additionalTextEdits = 'l',
|
||||||
command = 'm',
|
command = 'm',
|
||||||
kindModifier = 'n',
|
kindModifier = 'n',
|
||||||
|
|
||||||
// to merge into label
|
|
||||||
label2 = 'o',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISuggestDataDto {
|
export interface ISuggestDataDto {
|
||||||
[ISuggestDataDtoField.label]: string;
|
[ISuggestDataDtoField.label]: string | modes.CompletionItemLabel;
|
||||||
[ISuggestDataDtoField.label2]?: string | modes.CompletionItemLabel;
|
|
||||||
[ISuggestDataDtoField.kind]?: modes.CompletionItemKind;
|
[ISuggestDataDtoField.kind]?: modes.CompletionItemKind;
|
||||||
[ISuggestDataDtoField.detail]?: string;
|
[ISuggestDataDtoField.detail]?: string;
|
||||||
[ISuggestDataDtoField.documentation]?: string | IMarkdownString;
|
[ISuggestDataDtoField.documentation]?: string | IMarkdownString;
|
||||||
|
|
|
@ -987,8 +987,7 @@ class SuggestAdapter {
|
||||||
//
|
//
|
||||||
x: id,
|
x: id,
|
||||||
//
|
//
|
||||||
[extHostProtocol.ISuggestDataDtoField.label]: item.label ?? '',
|
[extHostProtocol.ISuggestDataDtoField.label]: item.label,
|
||||||
[extHostProtocol.ISuggestDataDtoField.label2]: item.label2,
|
|
||||||
[extHostProtocol.ISuggestDataDtoField.kind]: item.kind !== undefined ? typeConvert.CompletionItemKind.from(item.kind) : undefined,
|
[extHostProtocol.ISuggestDataDtoField.kind]: item.kind !== undefined ? typeConvert.CompletionItemKind.from(item.kind) : undefined,
|
||||||
[extHostProtocol.ISuggestDataDtoField.kindModifier]: item.tags && item.tags.map(typeConvert.CompletionItemTag.from),
|
[extHostProtocol.ISuggestDataDtoField.kindModifier]: item.tags && item.tags.map(typeConvert.CompletionItemTag.from),
|
||||||
[extHostProtocol.ISuggestDataDtoField.detail]: item.detail,
|
[extHostProtocol.ISuggestDataDtoField.detail]: item.detail,
|
||||||
|
|
|
@ -997,11 +997,7 @@ export namespace CompletionItem {
|
||||||
|
|
||||||
export function to(suggestion: modes.CompletionItem, converter?: CommandsConverter): types.CompletionItem {
|
export function to(suggestion: modes.CompletionItem, converter?: CommandsConverter): types.CompletionItem {
|
||||||
|
|
||||||
const result = new types.CompletionItem(typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.label);
|
const result = new types.CompletionItem(suggestion.label);
|
||||||
if (typeof suggestion.label !== 'string') {
|
|
||||||
result.label2 = suggestion.label;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.insertText = suggestion.insertText;
|
result.insertText = suggestion.insertText;
|
||||||
result.kind = CompletionItemKind.to(suggestion.kind);
|
result.kind = CompletionItemKind.to(suggestion.kind);
|
||||||
result.tags = suggestion.tags?.map(CompletionItemTag.to);
|
result.tags = suggestion.tags?.map(CompletionItemTag.to);
|
||||||
|
|
|
@ -1475,8 +1475,7 @@ export interface CompletionItemLabel {
|
||||||
@es5ClassCompat
|
@es5ClassCompat
|
||||||
export class CompletionItem implements vscode.CompletionItem {
|
export class CompletionItem implements vscode.CompletionItem {
|
||||||
|
|
||||||
label: string;
|
label: string | CompletionItemLabel;
|
||||||
label2?: CompletionItemLabel;
|
|
||||||
kind?: CompletionItemKind;
|
kind?: CompletionItemKind;
|
||||||
tags?: CompletionItemTag[];
|
tags?: CompletionItemTag[];
|
||||||
detail?: string;
|
detail?: string;
|
||||||
|
@ -1492,7 +1491,7 @@ export class CompletionItem implements vscode.CompletionItem {
|
||||||
additionalTextEdits?: TextEdit[];
|
additionalTextEdits?: TextEdit[];
|
||||||
command?: vscode.Command;
|
command?: vscode.Command;
|
||||||
|
|
||||||
constructor(label: string, kind?: CompletionItemKind) {
|
constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind) {
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
}
|
}
|
||||||
|
@ -1500,7 +1499,6 @@ export class CompletionItem implements vscode.CompletionItem {
|
||||||
toJSON(): any {
|
toJSON(): any {
|
||||||
return {
|
return {
|
||||||
label: this.label,
|
label: this.label,
|
||||||
label2: this.label2,
|
|
||||||
kind: this.kind && CompletionItemKind[this.kind],
|
kind: this.kind && CompletionItemKind[this.kind],
|
||||||
detail: this.detail,
|
detail: this.detail,
|
||||||
documentation: this.documentation,
|
documentation: this.documentation,
|
||||||
|
|
Loading…
Reference in a new issue