mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
debt - replace CompletionItem#overwriteBefore/After with CompletionItem#range
This commit is contained in:
@@ -378,7 +378,7 @@ export class ExtHostApiCommands {
|
||||
};
|
||||
return this._commands.executeCommand<modes.CompletionList>('_executeCompletionItemProvider', args).then(result => {
|
||||
if (result) {
|
||||
const items = result.suggestions.map(suggestion => typeConverters.Suggest.to(position, suggestion));
|
||||
const items = result.suggestions.map(suggestion => typeConverters.Suggest.to(suggestion));
|
||||
return new types.CompletionList(items, result.incomplete);
|
||||
}
|
||||
return undefined;
|
||||
|
||||
@@ -671,6 +671,7 @@ class SuggestAdapter {
|
||||
sortText: item.sortText,
|
||||
preselect: item.preselect,
|
||||
//
|
||||
range: undefined,
|
||||
insertText: undefined,
|
||||
additionalTextEdits: item.additionalTextEdits && item.additionalTextEdits.map(typeConvert.TextEdit.from),
|
||||
command: this._commands.toInternal(item.command),
|
||||
@@ -704,8 +705,7 @@ class SuggestAdapter {
|
||||
} else {
|
||||
range = defaultRange;
|
||||
}
|
||||
result.overwriteBefore = position.character - range.start.character;
|
||||
result.overwriteAfter = range.end.character - position.character;
|
||||
result.range = typeConvert.Range.from(range);
|
||||
|
||||
if (!range.isSingleLine || range.start.line !== position.line) {
|
||||
console.warn('INVALID text edit -> must be single line and on the same line');
|
||||
|
||||
@@ -544,7 +544,7 @@ export const CompletionItemKind = {
|
||||
|
||||
export namespace Suggest {
|
||||
|
||||
export function to(position: types.Position, suggestion: modes.CompletionItem): types.CompletionItem {
|
||||
export function to(suggestion: modes.CompletionItem): types.CompletionItem {
|
||||
const result = new types.CompletionItem(suggestion.label);
|
||||
result.insertText = suggestion.insertText;
|
||||
result.kind = CompletionItemKind.to(suggestion.kind);
|
||||
@@ -554,15 +554,7 @@ export namespace Suggest {
|
||||
result.filterText = suggestion.filterText;
|
||||
result.preselect = suggestion.preselect;
|
||||
result.commitCharacters = suggestion.commitCharacters;
|
||||
|
||||
// 'overwrite[Before|After]'-logic
|
||||
let overwriteBefore = (typeof suggestion.overwriteBefore === 'number') ? suggestion.overwriteBefore : 0;
|
||||
let startPosition = new types.Position(position.line, Math.max(0, position.character - overwriteBefore));
|
||||
let endPosition = position;
|
||||
if (typeof suggestion.overwriteAfter === 'number') {
|
||||
endPosition = new types.Position(position.line, position.character + suggestion.overwriteAfter);
|
||||
}
|
||||
result.range = new types.Range(startPosition, endPosition);
|
||||
result.range = Range.to(suggestion.range);
|
||||
|
||||
// 'inserText'-logic
|
||||
if (suggestion.insertTextIsSnippet) {
|
||||
|
||||
Reference in New Issue
Block a user