chore(vscode): update to 1.55.2

This commit is contained in:
Akash Satheesan
2021-04-09 11:32:27 +05:30
1102 changed files with 39988 additions and 23544 deletions

View File

@@ -174,8 +174,6 @@ export class CompletionModel {
wordLow = word.toLowerCase();
}
const textLabel = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name;
// remember the word against which this item was
// scored
item.word = word;
@@ -215,19 +213,19 @@ export class CompletionModel {
if (!match) {
continue; // NO match
}
if (compareIgnoreCase(item.completion.filterText, textLabel) === 0) {
if (compareIgnoreCase(item.completion.filterText, item.textLabel) === 0) {
// filterText and label are actually the same -> use good highlights
item.score = match;
} else {
// re-run the scorer on the label in the hope of a result BUT use the rank
// of the filterText-match
item.score = anyScore(word, wordLow, wordPos, textLabel, item.labelLow, 0);
item.score = anyScore(word, wordLow, wordPos, item.textLabel, item.labelLow, 0);
item.score[0] = match[0]; // use score from filterText
}
} else {
// by default match `word` against the `label`
let match = scoreFn(word, wordLow, wordPos, textLabel, item.labelLow, 0, false);
let match = scoreFn(word, wordLow, wordPos, item.textLabel, item.labelLow, 0, false);
if (!match) {
continue; // NO match
}
@@ -240,7 +238,7 @@ export class CompletionModel {
target.push(item as StrictCompletionItem);
// update stats
labelLengths.push(textLabel.length);
labelLengths.push(item.textLabel.length);
}
this._filteredItems = target.sort(this._snippetCompareFn);

View File

@@ -21,16 +21,17 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { assertType } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { localize } from 'vs/nls';
export const Context = {
Visible: new RawContextKey<boolean>('suggestWidgetVisible', false),
DetailsVisible: new RawContextKey<boolean>('suggestWidgetDetailsVisible', false),
MultipleSuggestions: new RawContextKey<boolean>('suggestWidgetMultipleSuggestions', false),
MakesTextEdit: new RawContextKey('suggestionMakesTextEdit', true),
AcceptSuggestionsOnEnter: new RawContextKey<boolean>('acceptSuggestionOnEnter', true),
HasInsertAndReplaceRange: new RawContextKey('suggestionHasInsertAndReplaceRange', false),
InsertMode: new RawContextKey<'insert' | 'replace'>('suggestionInsertMode', undefined),
CanResolve: new RawContextKey('suggestionCanResolve', false),
Visible: new RawContextKey<boolean>('suggestWidgetVisible', false, localize('suggestWidgetVisible', "Whether suggestion are visible")),
DetailsVisible: new RawContextKey<boolean>('suggestWidgetDetailsVisible', false, localize('suggestWidgetDetailsVisible', "Whether suggestion details are visible")),
MultipleSuggestions: new RawContextKey<boolean>('suggestWidgetMultipleSuggestions', false, localize('suggestWidgetMultipleSuggestions', "Whether there are multiple suggestions to pick from")),
MakesTextEdit: new RawContextKey('suggestionMakesTextEdit', true, localize('suggestionMakesTextEdit', "Whether inserting the current suggestion yields in a change or has everything already been typed")),
AcceptSuggestionsOnEnter: new RawContextKey<boolean>('acceptSuggestionOnEnter', true, localize('acceptSuggestionOnEnter', "Whether suggestions are inserted when pressing Enter")),
HasInsertAndReplaceRange: new RawContextKey('suggestionHasInsertAndReplaceRange', false, localize('suggestionHasInsertAndReplaceRange', "Whether the current suggestion has insert and replace behaviour")),
InsertMode: new RawContextKey<'insert' | 'replace'>('suggestionInsertMode', undefined, { type: 'string', description: localize('suggestionInsertMode', "Whether the default behaviour is to insert or replace") }),
CanResolve: new RawContextKey('suggestionCanResolve', false, localize('suggestionCanResolve', "Whether the current suggestion supports to resolve further details")),
};
export const suggestWidgetStatusbarMenu = new MenuId('suggestWidgetStatusBar');

View File

@@ -440,10 +440,9 @@ export class SuggestController implements IEditorContribution {
};
}
private _alertCompletionItem({ completion: suggestion }: CompletionItem): void {
const textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
if (isNonEmptyArray(suggestion.additionalTextEdits)) {
let msg = nls.localize('aria.alert.snippet', "Accepting '{0}' made {1} additional edits", textLabel, suggestion.additionalTextEdits.length);
private _alertCompletionItem(item: CompletionItem): void {
if (isNonEmptyArray(item.completion.additionalTextEdits)) {
let msg = nls.localize('aria.alert.snippet', "Accepting '{0}' made {1} additional edits", item.textLabel, item.completion.additionalTextEdits.length);
alert(msg);
}
}

View File

@@ -223,7 +223,6 @@ export class SuggestWidget implements IDisposable {
accessibilityProvider: {
getRole: () => 'option',
getAriaLabel: (item: CompletionItem) => {
const textLabel = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name;
if (item.isResolved && this._isDetailsVisible()) {
const { documentation, detail } = item.completion;
const docs = strings.format(
@@ -231,9 +230,9 @@ export class SuggestWidget implements IDisposable {
detail || '',
documentation ? (typeof documentation === 'string' ? documentation : documentation.value) : '');
return nls.localize('ariaCurrenttSuggestionReadDetails', "{0}, docs: {1}", textLabel, docs);
return nls.localize('ariaCurrenttSuggestionReadDetails', "{0}, docs: {1}", item.textLabel, docs);
} else {
return textLabel;
return item.textLabel;
}
},
getWidgetAriaLabel: () => nls.localize('suggest', "Suggest"),
@@ -670,7 +669,7 @@ export class SuggestWidget implements IDisposable {
this._details.hide();
this.element.domNode.classList.remove('shows-details');
} else if (canExpandCompletionItem(this._list.getFocusedElements()[0]) && (this._state === State.Open || this._state === State.Details || this._state === State.Frozen)) {
} else if ((canExpandCompletionItem(this._list.getFocusedElements()[0]) || this._explainMode) && (this._state === State.Open || this._state === State.Details || this._state === State.Frozen)) {
// show details widget (iff possible)
this._ctxSuggestWidgetDetailsVisible.set(true);
this._setDetailsVisible(true);
@@ -691,9 +690,13 @@ export class SuggestWidget implements IDisposable {
}
toggleExplainMode(): void {
if (this._list.getFocusedElements()[0] && this._isDetailsVisible()) {
if (this._list.getFocusedElements()[0]) {
this._explainMode = !this._explainMode;
this.showDetails(false);
if (!this._isDetailsVisible()) {
this.toggleDetails();
} else {
this.showDetails(false);
}
}
}

View File

@@ -128,10 +128,12 @@ export class SuggestDetailsWidget {
if (explainMode) {
let md = '';
md += `score: ${item.score[0]}${item.word ? `, compared '${item.completion.filterText && (item.completion.filterText + ' (filterText)') || typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name}' with '${item.word}'` : ' (no prefix)'}\n`;
md += `distance: ${item.distance}, see localityBonus-setting\n`;
md += `score: ${item.score[0]}\n`;
md += `prefix: ${item.word ?? '(no prefix)'}\n`;
md += `word: ${item.completion.filterText ? item.completion.filterText + ' (filterText)' : item.textLabel}\n`;
md += `distance: ${item.distance} (localityBonus-setting)\n`;
md += `index: ${item.idx}, based on ${item.completion.sortText && `sortText: "${item.completion.sortText}"` || 'label'}\n`;
md += `commit characters: ${item.completion.commitCharacters?.join('')}\n`;
md += `commit_chars: ${item.completion.commitCharacters?.join('')}\n`;
documentation = new MarkdownString().appendCodeblock('empty', md);
detail = `Provider: ${item.provider._debugDisplayName}`;
}

View File

@@ -162,8 +162,6 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
renderElement(element: CompletionItem, index: number, data: ISuggestionTemplateData): void {
const { completion } = element;
const textLabel = typeof completion.label === 'string' ? completion.label : completion.label.name;
data.root.id = getAriaId(index);
data.colorspan.style.backgroundColor = '';
@@ -183,7 +181,7 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
// special logic for 'file' completion items
data.icon.className = 'icon hide';
data.iconContainer.className = 'icon hide';
const labelClasses = getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: textLabel }), FileKind.FILE);
const labelClasses = getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: element.textLabel }), FileKind.FILE);
const detailClasses = getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: completion.detail }), FileKind.FILE);
labelOptions.extraClasses = labelClasses.length > detailClasses.length ? labelClasses : detailClasses;
@@ -192,7 +190,7 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
data.icon.className = 'icon hide';
data.iconContainer.className = 'icon hide';
labelOptions.extraClasses = flatten([
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: textLabel }), FileKind.FOLDER),
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: element.textLabel }), FileKind.FOLDER),
getIconClasses(this._modelService, this._modeService, URI.from({ scheme: 'fake', path: completion.detail }), FileKind.FOLDER)
]);
} else {
@@ -207,7 +205,7 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
labelOptions.matches = [];
}
data.iconLabel.setLabel(textLabel, undefined, labelOptions);
data.iconLabel.setLabel(element.textLabel, undefined, labelOptions);
if (typeof completion.label === 'string') {
data.parametersLabel.textContent = '';
data.qualifierLabel.textContent = '';
@@ -219,7 +217,7 @@ export class ItemRenderer implements IListRenderer<CompletionItem, ISuggestionTe
data.qualifierLabel.textContent = (completion.label.qualifier || '').replace(/\n.*$/m, '');
data.detailsLabel.textContent = (completion.label.type || '').replace(/\n.*$/m, '');
data.root.classList.remove('string-label');
data.root.title = `${textLabel}${completion.label.parameters ?? ''} ${completion.label.qualifier ?? ''} ${completion.label.type ?? ''}`;
data.root.title = `${element.textLabel}${completion.label.parameters ?? ''} ${completion.label.qualifier ?? ''} ${completion.label.type ?? ''}`;
}
if (this._editor.getOption(EditorOption.suggest).showInlineDetails) {

View File

@@ -50,14 +50,14 @@ export abstract class WordDistance {
delete wordRanges[wordUntilPos.word];
return new class extends WordDistance {
distance(anchor: IPosition, suggestion: CompletionItem) {
distance(anchor: IPosition, item: CompletionItem) {
if (!position.equals(editor.getPosition())) {
return 0;
}
if (suggestion.kind === CompletionItemKind.Keyword) {
if (item.kind === CompletionItemKind.Keyword) {
return 2 << 20;
}
let word = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
let word = typeof item.label === 'string' ? item.label : item.label.name;
let wordLines = wordRanges[word];
if (isFalsyOrEmpty(wordLines)) {
return 2 << 20;
@@ -78,5 +78,3 @@ export abstract class WordDistance {
abstract distance(anchor: IPosition, suggestion: CompletionItem): number;
}