TextEditor.edit snippet overload now returns void. No longer preventing when already in snippet mode.

This commit is contained in:
Joel Day
2017-01-17 23:25:40 -08:00
parent 713aaff9d8
commit 95fc03271c
8 changed files with 18 additions and 25 deletions

View File

@@ -137,7 +137,7 @@ export abstract class MainThreadEditorsShape {
$tryRevealRange(id: string, range: editorCommon.IRange, revealType: TextEditorRevealType): TPromise<any> { throw ni(); }
$trySetSelections(id: string, selections: editorCommon.ISelection[]): TPromise<any> { throw ni(); }
$tryApplyEdits(id: string, modelVersionId: number, edits: editorCommon.ISingleEditOperation[], opts: IApplyEditsOptions): TPromise<boolean> { throw ni(); }
$tryInsertSnippet(id: string, template: string, opts: IInsertSnippetOptions): TPromise<boolean> { throw ni(); }
$tryInsertSnippet(id: string, template: string, opts: IInsertSnippetOptions): TPromise<any> { throw ni(); }
}
export abstract class MainThreadTreeExplorersShape {

View File

@@ -596,11 +596,11 @@ 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(snippet: SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; }): void;
edit(callbackOrSnippet: ((edit: TextEditorEdit) => void) | SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable<boolean> {
edit(callbackOrSnippet: ((edit: TextEditorEdit) => void) | SnippetString, options: { undoStopBefore: boolean; undoStopAfter: boolean; } = { undoStopBefore: true, undoStopAfter: true }): Thenable<boolean> | void {
if (SnippetString.isSnippetString(callbackOrSnippet)) {
return this._proxy.$tryInsertSnippet(this._id, callbackOrSnippet.value, options);
this._proxy.$tryInsertSnippet(this._id, callbackOrSnippet.value, options);
} else {
let edit = new TextEditorEdit(this._documentData.document, options);
callbackOrSnippet(edit);

View File

@@ -293,11 +293,12 @@ export class MainThreadEditors extends MainThreadEditorsShape {
return TPromise.as(this._textEditorsMap[id].applyEdits(modelVersionId, edits, opts));
}
$tryInsertSnippet(id: string, template: string, opts: IInsertSnippetOptions): TPromise<boolean> {
$tryInsertSnippet(id: string, template: string, opts: IInsertSnippetOptions): TPromise<any> {
if (!this._textEditorsMap[id]) {
return TPromise.wrapError('TextEditor disposed');
}
return TPromise.as(this._textEditorsMap[id].insertSnippet(template, opts));
this._textEditorsMap[id].insertSnippet(template, opts);
return TPromise.as(null);
}
$registerTextEditorDecorationType(key: string, options: IDecorationRenderOptions): void {

View File

@@ -394,9 +394,6 @@ export class MainThreadTextEditor {
insertSnippet(template: string, opts: IInsertSnippetOptions) {
const snippetController = SnippetController.get(this._codeEditor);
if (snippetController.inSnippetMode) {
return false;
}
this._codeEditor.focus();
@@ -409,8 +406,6 @@ export class MainThreadTextEditor {
if (opts.undoStopAfter) {
this._codeEditor.pushUndoStop();
}
return true;
}
}