mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 02:28:34 +01:00
explicit insertSnippet function instead of edit overload, #19116
This commit is contained in:
@@ -595,17 +595,10 @@ class ExtHostTextEditor implements vscode.TextEditor {
|
||||
|
||||
// ---- editing
|
||||
|
||||
edit(callback: (edit: TextEditorEdit) => void, options: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
|
||||
edit(snippet: SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
|
||||
|
||||
edit(callbackOrSnippet: ((edit: TextEditorEdit) => void) | SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable<boolean> {
|
||||
if (SnippetString.isSnippetString(callbackOrSnippet)) {
|
||||
return this._proxy.$tryInsertSnippet(this._id, callbackOrSnippet.value, options);
|
||||
} else {
|
||||
let edit = new TextEditorEdit(this._documentData.document, options);
|
||||
callbackOrSnippet(edit);
|
||||
return this._applyEdit(edit);
|
||||
}
|
||||
edit(callback: (edit: TextEditorEdit) => void, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable<boolean> {
|
||||
let edit = new TextEditorEdit(this._documentData.document, options);
|
||||
callback(edit);
|
||||
return this._applyEdit(edit);
|
||||
}
|
||||
|
||||
_applyEdit(editBuilder: TextEditorEdit): TPromise<boolean> {
|
||||
@@ -627,6 +620,10 @@ class ExtHostTextEditor implements vscode.TextEditor {
|
||||
});
|
||||
}
|
||||
|
||||
insertSnippet(snippet: SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable<boolean> {
|
||||
return this._proxy.$tryInsertSnippet(this._id, snippet.value, options);
|
||||
}
|
||||
|
||||
// ---- util
|
||||
|
||||
private _runOnProxy(callback: () => TPromise<any>, silent: boolean): TPromise<ExtHostTextEditor> {
|
||||
|
||||
Reference in New Issue
Block a user