From e106d2968507fee74fdd278c7130884b21510434 Mon Sep 17 00:00:00 2001 From: XVincentX Date: Tue, 4 Oct 2016 18:53:02 +0200 Subject: [PATCH 1/2] Open the editor even when PREVIEW is selected. --- src/vs/workbench/browser/quickopen.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 72f5874fc41b6..e64a27bd82239 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -247,20 +247,16 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick } public run(mode: Mode, context: IEntryRunContext): boolean { - if (mode === Mode.OPEN) { - let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; + let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; - let input = this.getInput(); - if (input instanceof EditorInput) { - this.editorService.openEditor(input, this.getOptions(), sideBySide).done(null, errors.onUnexpectedError); - } else { - this.editorService.openEditor(input, sideBySide).done(null, errors.onUnexpectedError); - } - - return true; + let input = this.getInput(); + if (input instanceof EditorInput) { + this.editorService.openEditor(input, this.getOptions(), sideBySide).done(null, errors.onUnexpectedError); + } else { + this.editorService.openEditor(input, sideBySide).done(null, errors.onUnexpectedError); } - return false; + return mode === Mode.OPEN; } } From 322edd92a9eb28b53f2a35e0606ce41153ec0343 Mon Sep 17 00:00:00 2001 From: XVincentX Date: Tue, 4 Oct 2016 20:05:32 +0200 Subject: [PATCH 2/2] Set preserveFocus to true when opening a previewEditor --- src/vs/workbench/browser/quickopen.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index e64a27bd82239..dbe507aa106a4 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -250,13 +250,23 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; let input = this.getInput(); + let options = this.getOptions(); + + const isPreview = mode === Mode.PREVIEW; + if (input instanceof EditorInput) { - this.editorService.openEditor(input, this.getOptions(), sideBySide).done(null, errors.onUnexpectedError); + if (isPreview) { + options.preserveFocus = true; + } + this.editorService.openEditor(input, options, sideBySide).done(null, errors.onUnexpectedError); } else { + if (isPreview) { + (input).options.preserveFocus = true; + } this.editorService.openEditor(input, sideBySide).done(null, errors.onUnexpectedError); } - return mode === Mode.OPEN; + return !isPreview; } }