mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
add keepWhitespace-flag to completion item, #62057
This commit is contained in:
parent
d7f82c11d6
commit
01d8ba6b8c
7
src/vs/vscode.d.ts
vendored
7
src/vs/vscode.d.ts
vendored
|
@ -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.
|
||||
*
|
||||
|
|
27
src/vs/vscode.proposed.d.ts
vendored
27
src/vs/vscode.proposed.d.ts
vendored
|
@ -20,33 +20,6 @@ declare module 'vscode' {
|
|||
export function sampleFunction(): Thenable<any>;
|
||||
}
|
||||
|
||||
//#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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue