Skip to content

Commit 591a43e

Browse files
committed
label2
1 parent 7803c1d commit 591a43e

9 files changed

Lines changed: 38 additions & 35 deletions

File tree

src/vs/editor/common/modes.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,12 @@ export interface CompletionItemLabel {
376376
*/
377377
name: string;
378378

379-
/**
380-
* A description of the completion item which is rendered
381-
* less prominent.
382-
*/
383-
// description?: string;
379+
// The signature, without the return type. is render directly after `name`
380+
// signature?: string; // parameters
381+
// The fully qualified name, like package name, file path etc
382+
// qualifier?: string;
383+
// The return-type of a function or type of a property, variable etc
384+
// type?: string;
384385

385386
/**
386387
* Details of the completion item that is rendered less

src/vs/monaco.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5178,10 +5178,6 @@ declare namespace monaco.languages {
51785178
* The name of this completion item's label.
51795179
*/
51805180
name: string;
5181-
/**
5182-
* A description of the completion item which is rendered
5183-
* less prominent.
5184-
*/
51855181
/**
51865182
* Details of the completion item that is rendered less
51875183
* prominent to the right.

src/vs/vscode.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3360,7 +3360,7 @@ declare module 'vscode' {
33603360
* this is also the text that is inserted when selecting
33613361
* this completion.
33623362
*/
3363-
label: string | CompletionItemLabel;
3363+
label: string;
33643364

33653365
/**
33663366
* The kind of this completion item. Based on the kind

src/vs/vscode.proposed.d.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,23 +1529,27 @@ declare module 'vscode' {
15291529

15301530
//#region https://github.com/microsoft/vscode/issues/39441
15311531

1532+
export interface CompletionItem {
1533+
/**
1534+
* Will be merged into CompletionItem#label
1535+
*/
1536+
label2?: string | CompletionItemLabel;
1537+
}
1538+
15321539
export interface CompletionItemLabel {
15331540

15341541
/**
1535-
* The name of this completion item's label.
1542+
* The function or variable
15361543
*/
15371544
name: string;
15381545

1539-
/**
1540-
* A description of the completion item which is rendered
1541-
* less prominent.
1542-
*/
1543-
// description?: string;
1546+
// The signature, without the return type. is render directly after `name`
1547+
// signature?: string; // parameters
1548+
// The fully qualified name, like package name, file path etc
1549+
// qualifier?: string;
1550+
// The return-type of a function or type of a property, variable etc
1551+
// type?: string;
15441552

1545-
/**
1546-
* Details of the completion item that is rendered less
1547-
* prominent to the right.
1548-
*/
15491553
details?: string;
15501554
}
15511555

src/vs/workbench/api/browser/mainThreadLanguageFeatures.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,17 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
338338
// --- suggest
339339

340340
private static _inflateSuggestDto(defaultRange: IRange | { insert: IRange, replace: IRange }, data: ISuggestDataDto): modes.CompletionItem {
341-
const label = data[ISuggestDataDtoField.label];
342-
const labelText = typeof label === 'string'
343-
? label
344-
: label.name;
345341

346342
return {
347-
label: data[ISuggestDataDtoField.label],
343+
label: data[ISuggestDataDtoField.label2] || data[ISuggestDataDtoField.label],
348344
kind: data[ISuggestDataDtoField.kind],
349345
tags: data[ISuggestDataDtoField.kindModifier],
350346
detail: data[ISuggestDataDtoField.detail],
351347
documentation: data[ISuggestDataDtoField.documentation],
352348
sortText: data[ISuggestDataDtoField.sortText],
353349
filterText: data[ISuggestDataDtoField.filterText],
354350
preselect: data[ISuggestDataDtoField.preselect],
355-
insertText: typeof data.h === 'undefined' ? labelText : data.h,
351+
insertText: typeof data.h === 'undefined' ? data[ISuggestDataDtoField.label] : data.h,
356352
range: data[ISuggestDataDtoField.range] || defaultRange,
357353
insertTextRules: data[ISuggestDataDtoField.insertTextRules],
358354
commitCharacters: data[ISuggestDataDtoField.commitCharacters],

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,14 @@ export const enum ISuggestDataDtoField {
999999
additionalTextEdits = 'l',
10001000
command = 'm',
10011001
kindModifier = 'n',
1002+
1003+
// to merge into label
1004+
label2 = 'o',
10021005
}
10031006

10041007
export interface ISuggestDataDto {
1005-
[ISuggestDataDtoField.label]: string | modes.CompletionItemLabel;
1008+
[ISuggestDataDtoField.label]: string;
1009+
[ISuggestDataDtoField.label2]?: string | modes.CompletionItemLabel;
10061010
[ISuggestDataDtoField.kind]: modes.CompletionItemKind;
10071011
[ISuggestDataDtoField.detail]?: string;
10081012
[ISuggestDataDtoField.documentation]?: string | IMarkdownString;

src/vs/workbench/api/common/extHostLanguageFeatures.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,11 +896,7 @@ class SuggestAdapter {
896896
}
897897

898898
private _convertCompletionItem(item: vscode.CompletionItem, position: vscode.Position, id: extHostProtocol.ChainedCacheId): extHostProtocol.ISuggestDataDto | undefined {
899-
const label = typeof item.label === 'string'
900-
? item.label
901-
: item.label.name;
902-
903-
if (typeof label !== 'string' || label.length === 0) {
899+
if (typeof item.label !== 'string' || item.label.length === 0) {
904900
this._logService.warn('INVALID text edit -> must have at least a label');
905901
return undefined;
906902
}
@@ -915,6 +911,7 @@ class SuggestAdapter {
915911
x: id,
916912
//
917913
[extHostProtocol.ISuggestDataDtoField.label]: item.label,
914+
[extHostProtocol.ISuggestDataDtoField.label2]: item.label2,
918915
[extHostProtocol.ISuggestDataDtoField.kind]: typeConvert.CompletionItemKind.from(item.kind),
919916
[extHostProtocol.ISuggestDataDtoField.kindModifier]: item.tags && item.tags.map(typeConvert.CompletionItemTag.from),
920917
[extHostProtocol.ISuggestDataDtoField.detail]: item.detail,

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,9 @@ export namespace CompletionItemKind {
832832
export namespace CompletionItem {
833833

834834
export function to(suggestion: modes.CompletionItem, converter?: CommandsConverter): types.CompletionItem {
835-
const result = new types.CompletionItem(suggestion.label);
835+
836+
const result = new types.CompletionItem(typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name);
837+
result.label2 = suggestion.label;
836838
result.insertText = suggestion.insertText;
837839
result.kind = CompletionItemKind.to(suggestion.kind);
838840
result.tags = suggestion.tags && suggestion.tags.map(CompletionItemTag.to);

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,8 @@ export interface CompletionItemLabel {
13611361
@es5ClassCompat
13621362
export class CompletionItem implements vscode.CompletionItem {
13631363

1364-
label: string | CompletionItemLabel;
1364+
label: string;
1365+
label2?: string | CompletionItemLabel;
13651366
kind?: CompletionItemKind;
13661367
tags?: CompletionItemTag[];
13671368
detail?: string;
@@ -1377,14 +1378,16 @@ export class CompletionItem implements vscode.CompletionItem {
13771378
additionalTextEdits?: TextEdit[];
13781379
command?: vscode.Command;
13791380

1380-
constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind) {
1381+
constructor(label: string, kind?: CompletionItemKind) {
13811382
this.label = label;
1383+
this.label2 = { name: label };
13821384
this.kind = kind;
13831385
}
13841386

13851387
toJSON(): any {
13861388
return {
13871389
label: this.label,
1390+
label2: this.label2,
13881391
kind: this.kind && CompletionItemKind[this.kind],
13891392
detail: this.detail,
13901393
documentation: this.documentation,

0 commit comments

Comments
 (0)