diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index f7b5f8ee9e0..e8c81c72b4b 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3393,17 +3393,15 @@ declare module 'vscode' { insertText?: string | SnippetString; /** - * A range or a insert and replace range selecting the text that should be replaced by this completion item. + * A range of 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. + * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the + * current position. * - * *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must + * *Note:* The 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 | { insert: Range; replace: Range; }; + range?: 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 6f6c6f7db47..206e5baeeaa 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -997,4 +997,24 @@ declare module 'vscode' { } //#endregion + + //#region joh, 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 | { insert: Range; replace: Range; }; + } + + //#endregion } diff --git a/src/vs/workbench/api/common/extHostLanguageFeatures.ts b/src/vs/workbench/api/common/extHostLanguageFeatures.ts index ee1f78b5490..d81bc8e27a1 100644 --- a/src/vs/workbench/api/common/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/common/extHostLanguageFeatures.ts @@ -756,6 +756,8 @@ class SuggestAdapter { range = item.textEdit.range; } else if (item.range) { range = item.range; + } else if (item.range2) { + range = item.range2; } if (range) { diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 0708d0173b9..f6f1c610236 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -1343,7 +1343,8 @@ export class CompletionItem implements vscode.CompletionItem { preselect?: boolean; insertText?: string | SnippetString; keepWhitespace?: boolean; - range?: Range | { insert: Range; replace: Range; }; + range?: Range; + range2?: Range | { insert: Range; replace: Range; }; commitCharacters?: string[]; textEdit?: TextEdit; additionalTextEdits?: TextEdit[];