diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index cf02afe365ee275b7890d75215439c834e7c6c5e..a2b3112bc8076502f2a1dca318ce663979eb605a 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3413,15 +3413,17 @@ declare module 'vscode' { insertText?: string | SnippetString; /** - * A range of text that should be replaced by this completion item. + * A range or a insert and replace range selecting the text that should be replaced by this completion item. * - * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the - * current position. + * When omitted, the range of the [current word](#TextDocument.getWordRangeAtPosition) is used as replace-range + * and as insert-range the start of the [current word](#TextDocument.getWordRangeAtPosition) to the + * current position is used. * - * *Note:* The range must be a [single line](#Range.isSingleLine) and it must + * *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). + * *Note 2:* A insert range must be a prefix of a replace range, that means it must be contained and starting at the same position. */ - range?: Range; + range?: Range | { inserting: Range; replacing: Range; }; /** * An optional set of characters that when pressed while this completion is active will accept it first and diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index c6103fbe208749ee3207cfb3efd7fb89d2511e47..0de7f957f3f1f08156f9204969b9d6f7e595fca2 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1285,25 +1285,6 @@ declare module 'vscode' { //#endregion - //#region insert/replace completions: https://github.com/microsoft/vscode/issues/10266 - - export interface CompletionItem { - - /** - * A range or a insert and replace range selecting the text that should be replaced by this completion item. - * - * When omitted, the range of the [current word](#TextDocument.getWordRangeAtPosition) is used as replace-range - * and as insert-range the start of the [current word](#TextDocument.getWordRangeAtPosition) to the - * current position is used. - * - * *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must - * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). - * *Note 2:* A insert range must be a prefix of a replace range, that means it must be contained and starting at the same position. - */ - range2?: Range | { inserting: Range; replacing: Range; }; - } - - //#endregion //#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904 diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index 20cc1a12f77d244fc0b3abbdb3f2ea8dcfc27fc3..f3cb6fade937de784f85437671da19003150e3d6 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -918,8 +918,6 @@ class SuggestAdapter { range = item.textEdit.range; } else if (item.range) { range = item.range; - } else if (item.range2) { - range = item.range2; } if (range) { @@ -955,12 +953,12 @@ class SuggestAdapter { } private static _mustNotChangeHash(item: vscode.CompletionItem) { - const res = JSON.stringify([item.label, item.sortText, item.filterText, item.insertText, item.range, item.range2]); + const res = JSON.stringify([item.label, item.sortText, item.filterText, item.insertText, item.range]); return res; } private static _mustNotChangeDiff(hash: string, item: vscode.CompletionItem): string | void { - const thisArr = [item.label, item.sortText, item.filterText, item.insertText, item.range, item.range2]; + const thisArr = [item.label, item.sortText, item.filterText, item.insertText, item.range]; const thisHash = JSON.stringify(thisArr); if (hash === thisHash) { return; diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index 093a3219eb5aa092b4c7a46b1cd020d01c208f97..6875799dc6983e28f6c618444c7e9ba53410c4c5 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -842,8 +842,14 @@ export namespace CompletionItem { result.filterText = suggestion.filterText; result.preselect = suggestion.preselect; result.commitCharacters = suggestion.commitCharacters; - result.range = editorRange.Range.isIRange(suggestion.range) ? Range.to(suggestion.range) : undefined; - result.range2 = editorRange.Range.isIRange(suggestion.range) ? undefined : { inserting: Range.to(suggestion.range.insert), replacing: Range.to(suggestion.range.replace) }; + + // range + if (editorRange.Range.isIRange(suggestion.range)) { + result.range = Range.to(suggestion.range); + } else if (typeof suggestion.range === 'object') { + result.range = { inserting: Range.to(suggestion.range.insert), replacing: Range.to(suggestion.range.replace) }; + } + result.keepWhitespace = typeof suggestion.insertTextRules === 'undefined' ? false : Boolean(suggestion.insertTextRules & modes.CompletionItemInsertTextRule.KeepWhitespace); // 'insertText'-logic if (typeof suggestion.insertTextRules !== 'undefined' && suggestion.insertTextRules & modes.CompletionItemInsertTextRule.InsertAsSnippet) { diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index eeb89627d62607b128df599ecf66a082fb2c3732..037eb2b99a4e0fb6ccb34ef102fb878306b3661e 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1364,8 +1364,7 @@ export class CompletionItem implements vscode.CompletionItem { preselect?: boolean; insertText?: string | SnippetString; keepWhitespace?: boolean; - range?: Range; - range2?: Range | { inserting: Range; replacing: Range; }; + range?: Range | { inserting: Range; replacing: Range; }; commitCharacters?: string[]; textEdit?: TextEdit; additionalTextEdits?: TextEdit[];