From a2c4a0ca8ca8b86e8dd32e20e596a2e00bfdeaf9 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 22 Jun 2021 13:59:29 +0200 Subject: [PATCH] use label, detail, and description for CompletionItemLabel, tweak rendering, https://github.com/microsoft/vscode/issues/39441 --- src/vs/editor/common/modes.ts | 22 +++---------------- .../editor/contrib/suggest/media/suggest.css | 5 +++-- src/vs/editor/contrib/suggest/suggest.ts | 4 ++-- .../contrib/suggest/suggestWidgetRenderer.ts | 8 ++----- src/vs/editor/contrib/suggest/wordDistance.ts | 2 +- src/vs/monaco.d.ts | 19 +++------------- src/vs/vscode.proposed.d.ts | 21 +++++++----------- .../api/common/extHostTypeConverters.ts | 2 +- src/vs/workbench/api/common/extHostTypes.ts | 8 +++---- .../browser/snippetCompletionProvider.ts | 8 +++---- 10 files changed, 30 insertions(+), 69 deletions(-) diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index 76b00784ef481..d9863fff7fe79 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -487,25 +487,9 @@ export let completionKindFromString: { })(); export interface CompletionItemLabel { - /** - * The function or variable. Rendered leftmost. - */ - name: string; - - /** - * The parameters without the return type. Render after `name`. - */ - signature?: string; - - /** - * The fully qualified name, like package name or file path. Rendered after `signature`. - */ - qualifier?: string; - - /** - * The return-type of a function or type of a property/variable. Rendered rightmost. - */ - type?: string; + label: string; + detail?: string; + description?: string; } export const enum CompletionItemTag { diff --git a/src/vs/editor/contrib/suggest/media/suggest.css b/src/vs/editor/contrib/suggest/media/suggest.css index a79237e754310..afef49ab7b91a 100644 --- a/src/vs/editor/contrib/suggest/media/suggest.css +++ b/src/vs/editor/contrib/suggest/media/suggest.css @@ -166,9 +166,9 @@ } .monaco-editor .suggest-widget .monaco-list .monaco-list-row>.contents>.main>.left>.qualifier-label { - margin-left: 4px; + margin-left: 12px; opacity: 0.4; - font-size: 90%; + font-size: 85%; line-height: initial; text-overflow: ellipsis; overflow: hidden; @@ -178,6 +178,7 @@ /** Type Info and icon next to the label in the focused completion item **/ .monaco-editor .suggest-widget .monaco-list .monaco-list-row>.contents>.main>.right>.details-label { + font-size: 85%; margin-left: 1.1em; overflow: hidden; text-overflow: ellipsis; diff --git a/src/vs/editor/contrib/suggest/suggest.ts b/src/vs/editor/contrib/suggest/suggest.ts index ec192ae88cfee..6729ec47a9436 100644 --- a/src/vs/editor/contrib/suggest/suggest.ts +++ b/src/vs/editor/contrib/suggest/suggest.ts @@ -74,7 +74,7 @@ export class CompletionItem { ) { this.textLabel = typeof completion.label === 'string' ? completion.label - : completion.label.name; + : completion.label.label; // ensure lower-variants (perf) this.labelLow = this.textLabel.toLowerCase(); @@ -227,7 +227,7 @@ export async function provideSuggestionItems( } // fill in default sortText when missing if (!suggestion.sortText) { - suggestion.sortText = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name; + suggestion.sortText = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.label; } if (!needsClipboard && suggestion.insertTextRules && suggestion.insertTextRules & modes.CompletionItemInsertTextRule.InsertAsSnippet) { needsClipboard = SnippetParser.guessNeedsClipboard(suggestion.insertText); diff --git a/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts b/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts index b466ee9feb14b..7db2c65d3d05f 100644 --- a/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts +++ b/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts @@ -208,16 +208,12 @@ export class ItemRenderer implements IListRenderer i + 1) { - suggestions[i].label.name = localize('snippetSuggest.longLabel', "{0}, {1}", suggestions[i].label.name, suggestions[i].snippet.name); + suggestions[i].label.label = localize('snippetSuggest.longLabel', "{0}, {1}", suggestions[i].label.label, suggestions[i].snippet.name); i = to; } }