diff --git a/extensions/vscode-api-tests/src/editor.test.ts b/extensions/vscode-api-tests/src/editor.test.ts index 1eafbc23530..6d82de1062b 100644 --- a/extensions/vscode-api-tests/src/editor.test.ts +++ b/extensions/vscode-api-tests/src/editor.test.ts @@ -41,7 +41,7 @@ suite('editor tests', () => { .appendText(' snippet'); return withRandomFileEditor('', (editor, doc) => { - return editor.edit(snippetString).then(inserted => { + return editor.insertSnippet(snippetString).then(inserted => { assert.ok(inserted); assert.equal(doc.getText(), 'This is a placeholder snippet'); assert.ok(doc.isDirty); @@ -59,7 +59,7 @@ suite('editor tests', () => { new Position(0, 12) ); - return editor.edit(snippetString).then(inserted => { + return editor.insertSnippet(snippetString).then(inserted => { assert.ok(inserted); assert.equal(doc.getText(), 'This has been replaced'); assert.ok(doc.isDirty); diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 3623754e4a2..3aef9cd5140 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -947,7 +947,7 @@ declare module 'vscode' { * @param options The undo/redo behaviour around this edit. By default, undo stops will be created before and after this edit. * @return A promise that resolves with a value indicating if the snippet could be inserted. */ - edit(snippet: SnippetString, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable; + insertSnippet(snippet: SnippetString, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable; /** * Adds a set of decorations to the text editor. If a set of decorations already exists with diff --git a/src/vs/workbench/api/node/extHostEditors.ts b/src/vs/workbench/api/node/extHostEditors.ts index 3a65e8da293..4e48af136f1 100644 --- a/src/vs/workbench/api/node/extHostEditors.ts +++ b/src/vs/workbench/api/node/extHostEditors.ts @@ -595,17 +595,10 @@ class ExtHostTextEditor implements vscode.TextEditor { // ---- editing - edit(callback: (edit: TextEditorEdit) => void, options: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable; - edit(snippet: SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable; - - edit(callbackOrSnippet: ((edit: TextEditorEdit) => void) | SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable { - 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 { + let edit = new TextEditorEdit(this._documentData.document, options); + callback(edit); + return this._applyEdit(edit); } _applyEdit(editBuilder: TextEditorEdit): TPromise { @@ -627,6 +620,10 @@ class ExtHostTextEditor implements vscode.TextEditor { }); } + insertSnippet(snippet: SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable { + return this._proxy.$tryInsertSnippet(this._id, snippet.value, options); + } + // ---- util private _runOnProxy(callback: () => TPromise, silent: boolean): TPromise {