diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 1bd37d77e13..ae956d9842b 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -3249,6 +3249,13 @@ declare module 'vscode' { */ commitCharacters?: string[]; + /** + * Keep whitespace of the [insertText](#CompletionItem.insertText) as is. By default, the editor adjusts leading + * whitespace of new lines so that they match the indentation of the line for which the item is accepeted - setting + * this to `true` will prevent that. + */ + keepWhitespace?: boolean; + /** * @deprecated Use `CompletionItem.insertText` and `CompletionItem.range` instead. * diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 31bbbe43cb1..589a0326445 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -20,33 +20,6 @@ declare module 'vscode' { export function sampleFunction(): Thenable; } - //#region Joh - https://github.com/Microsoft/vscode/issues/57093 - - /** - * An insert text rule defines how the [`insertText`](#CompletionItem.insertText) of a - * completion item should be modified. - */ - export enum CompletionItemInsertTextRule { - - /** - * Keep whitespace as is. By default, the editor adjusts leading - * whitespace of new lines so that they match the indentation of - * the line for which the item is accepeted. - */ - KeepWhitespace = 0b01 - } - - export interface CompletionItem { - - /** - * Rules about how/if the `insertText` should be modified by the - * editor. Can be a bit mask of many rules. - */ - insertTextRules?: CompletionItemInsertTextRule; - } - - //#endregion - //#region Joh - read/write in chunks export interface FileSystemProvider { diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 834d2df052a..8121df2ac83 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -744,7 +744,6 @@ export function createApiFactory( CommentThreadCollapsibleState: extHostTypes.CommentThreadCollapsibleState, CompletionItem: extHostTypes.CompletionItem, CompletionItemKind: extHostTypes.CompletionItemKind, - CompletionItemInsertTextRule: extension.enableProposedApi ? extHostTypes.CompletionItemInsertTextRule : null, CompletionList: extHostTypes.CompletionList, CompletionTriggerKind: extHostTypes.CompletionTriggerKind, ConfigurationTarget: extHostTypes.ConfigurationTarget, diff --git a/src/vs/workbench/api/node/extHostLanguageFeatures.ts b/src/vs/workbench/api/node/extHostLanguageFeatures.ts index e9696659033..6e12e68ca9b 100644 --- a/src/vs/workbench/api/node/extHostLanguageFeatures.ts +++ b/src/vs/workbench/api/node/extHostLanguageFeatures.ts @@ -685,7 +685,7 @@ class SuggestAdapter { // range: undefined, insertText: undefined, - insertTextRules: typeConvert.CompletionItemInsertTextRule.from(item.insertTextRules), + insertTextRules: item.keepWhitespace ? modes.CompletionItemInsertTextRule.KeepWhitespace : 0, additionalTextEdits: item.additionalTextEdits && item.additionalTextEdits.map(typeConvert.TextEdit.from), command: this._commands.toInternal(item.command), commitCharacters: item.commitCharacters, diff --git a/src/vs/workbench/api/node/extHostTypeConverters.ts b/src/vs/workbench/api/node/extHostTypeConverters.ts index 0bbe5c7e66b..e50f4755d58 100644 --- a/src/vs/workbench/api/node/extHostTypeConverters.ts +++ b/src/vs/workbench/api/node/extHostTypeConverters.ts @@ -681,25 +681,6 @@ export namespace CompletionItemKind { } } -export namespace CompletionItemInsertTextRule { - - export function from(rule: types.CompletionItemInsertTextRule): modes.CompletionItemInsertTextRule { - let result = 0; - if ((rule & types.CompletionItemInsertTextRule.KeepWhitespace)) { - result += modes.CompletionItemInsertTextRule.KeepWhitespace; - } - return result; - } - - export function to(rule: modes.CompletionItemInsertTextRule): types.CompletionItemInsertTextRule { - let result = 0; - if ((rule & modes.CompletionItemInsertTextRule.KeepWhitespace)) { - result += types.CompletionItemInsertTextRule.KeepWhitespace; - } - return result; - } -} - export namespace CompletionItem { export function to(suggestion: modes.CompletionItem): types.CompletionItem { @@ -713,7 +694,7 @@ export namespace CompletionItem { result.preselect = suggestion.preselect; result.commitCharacters = suggestion.commitCharacters; result.range = Range.to(suggestion.range); - result.insertTextRules = CompletionItemInsertTextRule.to(suggestion.insertTextRules); + result.keepWhitespace = Boolean(suggestion.insertTextRules & modes.CompletionItemInsertTextRule.KeepWhitespace); // 'inserText'-logic if (suggestion.insertTextRules & modes.CompletionItemInsertTextRule.InsertAsSnippet) { result.insertText = new types.SnippetString(suggestion.insertText); diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index f4d5445d036..62a81f6a104 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -1163,10 +1163,6 @@ export enum CompletionItemKind { TypeParameter = 24 } -export enum CompletionItemInsertTextRule { - KeepWhitespace = 0b1 -} - export class CompletionItem implements vscode.CompletionItem { label: string; @@ -1177,7 +1173,7 @@ export class CompletionItem implements vscode.CompletionItem { filterText: string; preselect: boolean; insertText: string | SnippetString; - insertTextRules: CompletionItemInsertTextRule; + keepWhitespace?: boolean; range: Range; commitCharacters: string[]; textEdit: TextEdit;