提交 31ec4fe4 编写于 作者: P Pine Wu

CompletionItemLabel#label -> name

上级 79a01a0f
......@@ -372,11 +372,9 @@ export let completionKindFromString: {
export interface CompletionItemLabel {
/**
* The label of this completion item. By default
* this is also the text that is inserted when selecting
* this completion.
* The name of this completion item's label.
*/
label: string;
name: string;
/**
* A description of the completion item which is rendered
......
......@@ -192,7 +192,7 @@ export class CompletionModel {
}
}
const label = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.label;
const label = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name;
if (wordPos >= wordLen) {
// the wordPos at which scoring starts is the whole word
// and therefore the same rules as not having a word apply
......
......@@ -59,7 +59,7 @@ export class CompletionItem {
) {
this.textLabel = typeof completion.label === 'string'
? completion.label
: completion.label.label;
: completion.label.name;
// ensure lower-variants (perf)
this.labelLow = this.textLabel.toLowerCase();
......@@ -191,7 +191,7 @@ export function provideSuggestionItems(
}
// fill in default sortText when missing
if (!suggestion.sortText) {
suggestion.sortText = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.label;
suggestion.sortText = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
}
allSuggestions.push(new CompletionItem(position, suggestion, container, provider, model));
......
......@@ -343,7 +343,7 @@ export class SuggestController implements IEditorContribution {
}
private _alertCompletionItem({ completion: suggestion }: CompletionItem): void {
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.label;
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
if (isNonEmptyArray(suggestion.additionalTextEdits)) {
let msg = nls.localize('arai.alert.snippet', "Accepting '{0}' made {1} additional edits", textLabel, suggestion.additionalTextEdits.length);
alert(msg);
......
......@@ -69,7 +69,7 @@ const colorRegExp = /^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1
function extractColor(item: CompletionItem, out: string[]): boolean {
const label = typeof item.completion.label === 'string'
? item.completion.label
: item.completion.label.label;
: item.completion.label.name;
if (label.match(colorRegExp)) {
out[0] = label;
......@@ -167,7 +167,7 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
renderElement(element: CompletionItem, _index: number, templateData: ISuggestionTemplateData): void {
const data = <ISuggestionTemplateData>templateData;
const suggestion = (<CompletionItem>element).completion;
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.label;
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
data.icon.className = 'icon ' + completionKindToCssClass(suggestion.kind);
data.colorspan.style.backgroundColor = '';
......@@ -630,7 +630,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
}
private _getSuggestionAriaAlertLabel(item: CompletionItem): string {
const textLabel = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.label;
const textLabel = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name;
if (this.expandDocsSettingFromStorage()) {
return nls.localize('ariaCurrenttSuggestionReadDetails', "Item {0}, docs: {1}", textLabel, this.details.getAriaLabel());
} else {
......
......@@ -50,7 +50,7 @@ export abstract class WordDistance {
}
let word = typeof suggestion.label === 'string'
? suggestion.label
: suggestion.label.label;
: suggestion.label.name;
let wordLines = wordRanges[word];
if (isFalsyOrEmpty(wordLines)) {
......
......@@ -4746,11 +4746,9 @@ declare namespace monaco.languages {
export interface CompletionItemLabel {
/**
* The label of this completion item. By default
* this is also the text that is inserted when selecting
* this completion.
* The name of this completion item's label.
*/
label: string;
name: string;
/**
* A description of the completion item which is rendered
* less prominent.
......
......@@ -1512,11 +1512,9 @@ declare module 'vscode' {
export interface CompletionItemLabel {
/**
* The label of this completion item. By default
* this is also the text that is inserted when selecting
* this completion.
* The name of this completion item's label.
*/
label: string;
name: string;
/**
* A description of the completion item which is rendered
......
......@@ -337,7 +337,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
const label = data[ISuggestDataDtoField.label];
const labelText = typeof label === 'string'
? label
: label.label;
: label.name;
return {
label: data[ISuggestDataDtoField.label],
......
......@@ -859,7 +859,7 @@ class SuggestAdapter {
private _convertCompletionItem(item: vscode.CompletionItem, position: vscode.Position, id: extHostProtocol.ChainedCacheId): extHostProtocol.ISuggestDataDto | undefined {
const label = typeof item.label === 'string'
? item.label
: item.label.label;
: item.label.name;
if (typeof label !== 'string' || label.length === 0) {
this._logService.warn('INVALID text edit -> must have at least a label');
......
......@@ -1352,7 +1352,7 @@ export enum CompletionItemTag {
}
export interface CompletionItemLabel {
label: string;
name: string;
// description?: string;
details?: string;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册