Skip to content

Commit fcb807c

Browse files
committed
move insert/replace range API to proposed
1 parent ec6d344 commit fcb807c

4 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/vs/vscode.d.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,17 +3393,15 @@ declare module 'vscode' {
33933393
insertText?: string | SnippetString;
33943394

33953395
/**
3396-
* A range or a insert and replace range selecting the text that should be replaced by this completion item.
3396+
* A range of text that should be replaced by this completion item.
33973397
*
3398-
* When omitted, the range of the [current word](#TextDocument.getWordRangeAtPosition) is used as replace-range
3399-
* and as insert-range the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
3400-
* current position is used.
3398+
* Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
3399+
* current position.
34013400
*
3402-
* *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must
3401+
* *Note:* The range must be a [single line](#Range.isSingleLine) and it must
34033402
* [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
3404-
* *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.
34053403
*/
3406-
range?: Range | { insert: Range; replace: Range; };
3404+
range?: Range;
34073405

34083406
/**
34093407
* An optional set of characters that when pressed while this completion is active will accept it first and

src/vs/vscode.proposed.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,4 +997,24 @@ declare module 'vscode' {
997997
}
998998

999999
//#endregion
1000+
1001+
//#region joh, insert/replace completions: https://github.com/microsoft/vscode/issues/10266
1002+
1003+
export interface CompletionItem {
1004+
1005+
/**
1006+
* A range or a insert and replace range selecting the text that should be replaced by this completion item.
1007+
*
1008+
* When omitted, the range of the [current word](#TextDocument.getWordRangeAtPosition) is used as replace-range
1009+
* and as insert-range the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
1010+
* current position is used.
1011+
*
1012+
* *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must
1013+
* [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
1014+
* *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.
1015+
*/
1016+
range2?: Range | { insert: Range; replace: Range; };
1017+
}
1018+
1019+
//#endregion
10001020
}

src/vs/workbench/api/common/extHostLanguageFeatures.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ class SuggestAdapter {
756756
range = item.textEdit.range;
757757
} else if (item.range) {
758758
range = item.range;
759+
} else if (item.range2) {
760+
range = item.range2;
759761
}
760762

761763
if (range) {

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,8 @@ export class CompletionItem implements vscode.CompletionItem {
13431343
preselect?: boolean;
13441344
insertText?: string | SnippetString;
13451345
keepWhitespace?: boolean;
1346-
range?: Range | { insert: Range; replace: Range; };
1346+
range?: Range;
1347+
range2?: Range | { insert: Range; replace: Range; };
13471348
commitCharacters?: string[];
13481349
textEdit?: TextEdit;
13491350
additionalTextEdits?: TextEdit[];

0 commit comments

Comments
 (0)