mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
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[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@ -4041,7 +4066,7 @@ declare module 'vscode' {
|
|||
* this is also the text that is inserted when selecting
|
||||
* this completion.
|
||||
*/
|
||||
label: string;
|
||||
label: string | CompletionItemLabel;
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
|
||||
//#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
|
||||
|
||||
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 {
|
||||
|
||||
const label = data[ISuggestDataDtoField.label];
|
||||
|
||||
return {
|
||||
label: data[ISuggestDataDtoField.label2] ?? data[ISuggestDataDtoField.label],
|
||||
label,
|
||||
kind: data[ISuggestDataDtoField.kind] ?? modes.CompletionItemKind.Property,
|
||||
tags: data[ISuggestDataDtoField.kindModifier],
|
||||
detail: data[ISuggestDataDtoField.detail],
|
||||
|
@ -452,7 +454,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
|||
sortText: data[ISuggestDataDtoField.sortText],
|
||||
filterText: data[ISuggestDataDtoField.filterText],
|
||||
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,
|
||||
insertTextRules: data[ISuggestDataDtoField.insertTextRules],
|
||||
commitCharacters: data[ISuggestDataDtoField.commitCharacters],
|
||||
|
|
|
@ -1392,14 +1392,10 @@ export const enum ISuggestDataDtoField {
|
|||
additionalTextEdits = 'l',
|
||||
command = 'm',
|
||||
kindModifier = 'n',
|
||||
|
||||
// to merge into label
|
||||
label2 = 'o',
|
||||
}
|
||||
|
||||
export interface ISuggestDataDto {
|
||||
[ISuggestDataDtoField.label]: string;
|
||||
[ISuggestDataDtoField.label2]?: string | modes.CompletionItemLabel;
|
||||
[ISuggestDataDtoField.label]: string | modes.CompletionItemLabel;
|
||||
[ISuggestDataDtoField.kind]?: modes.CompletionItemKind;
|
||||
[ISuggestDataDtoField.detail]?: string;
|
||||
[ISuggestDataDtoField.documentation]?: string | IMarkdownString;
|
||||
|
|
|
@ -987,8 +987,7 @@ class SuggestAdapter {
|
|||
//
|
||||
x: id,
|
||||
//
|
||||
[extHostProtocol.ISuggestDataDtoField.label]: item.label ?? '',
|
||||
[extHostProtocol.ISuggestDataDtoField.label2]: item.label2,
|
||||
[extHostProtocol.ISuggestDataDtoField.label]: item.label,
|
||||
[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.detail]: item.detail,
|
||||
|
|
|
@ -997,11 +997,7 @@ export namespace 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);
|
||||
if (typeof suggestion.label !== 'string') {
|
||||
result.label2 = suggestion.label;
|
||||
}
|
||||
|
||||
const result = new types.CompletionItem(suggestion.label);
|
||||
result.insertText = suggestion.insertText;
|
||||
result.kind = CompletionItemKind.to(suggestion.kind);
|
||||
result.tags = suggestion.tags?.map(CompletionItemTag.to);
|
||||
|
|
|
@ -1475,8 +1475,7 @@ export interface CompletionItemLabel {
|
|||
@es5ClassCompat
|
||||
export class CompletionItem implements vscode.CompletionItem {
|
||||
|
||||
label: string;
|
||||
label2?: CompletionItemLabel;
|
||||
label: string | CompletionItemLabel;
|
||||
kind?: CompletionItemKind;
|
||||
tags?: CompletionItemTag[];
|
||||
detail?: string;
|
||||
|
@ -1492,7 +1491,7 @@ export class CompletionItem implements vscode.CompletionItem {
|
|||
additionalTextEdits?: TextEdit[];
|
||||
command?: vscode.Command;
|
||||
|
||||
constructor(label: string, kind?: CompletionItemKind) {
|
||||
constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind) {
|
||||
this.label = label;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
@ -1500,7 +1499,6 @@ export class CompletionItem implements vscode.CompletionItem {
|
|||
toJSON(): any {
|
||||
return {
|
||||
label: this.label,
|
||||
label2: this.label2,
|
||||
kind: this.kind && CompletionItemKind[this.kind],
|
||||
detail: this.detail,
|
||||
documentation: this.documentation,
|
||||
|
|
Loading…
Reference in a new issue