diff --git a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts index cc3c2d2bc2c03dc28e7a30f62f28f91f72e1c854..6bfa095377b52dc4bf4e5ecd7b1bfa8a3f12827e 100644 --- a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts +++ b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts @@ -171,7 +171,7 @@ export class QuickOpenWidget implements IModelProvider { const focus = this.tree.getFocus(); if (focus) { - this.elementSelected(focus, keyboardEvent); + this.elementSelected(focus, keyboardEvent, keyboardEvent.keyCode === KeyCode.RightArrow ? Mode.OPEN_IN_BACKGROUND : Mode.OPEN); } } @@ -401,23 +401,14 @@ export class QuickOpenWidget implements IModelProvider { this.model.runner.run(value, Mode.PREVIEW, context); } - private elementSelected(value: any, event?: any): void { + private elementSelected(value: any, event?: any, preferredMode?: Mode): void { let hide = true; // Trigger open of element on selection if (this.isVisible()) { - let eventForContext = event; - let mode = Mode.OPEN; + let mode = preferredMode || Mode.OPEN; - if (event instanceof StandardKeyboardEvent) { - eventForContext = event.browserEvent; - - if (event.keyCode === KeyCode.RightArrow) { - mode = Mode.OPEN_IN_BACKGROUND; - } - } - - const context: IEntryRunContext = { event: eventForContext, keymods: this.extractKeyMods(eventForContext), quickNavigateConfiguration: this.quickNavigateConfiguration }; + const context: IEntryRunContext = { event, keymods: this.extractKeyMods(event), quickNavigateConfiguration: this.quickNavigateConfiguration }; hide = this.model.runner.run(value, mode, context); } diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 3713a0057a41affbffd0fcb2e29af9e9d5cd1ad1..fae478e3de57801ea561acda1d608bcad45f63cc 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -18,7 +18,7 @@ import { KeyMod } from 'vs/base/common/keyCodes'; import { Mode, IEntryRunContext, IAutoFocus, IModel, IQuickNavigateConfiguration } from 'vs/base/parts/quickopen/common/quickOpen'; import { QuickOpenEntry, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { EditorOptions, EditorInput } from 'vs/workbench/common/editor'; -import { IResourceInput, IEditorInput } from 'vs/platform/editor/common/editor'; +import { IResourceInput, IEditorInput, IEditorOptions } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; @@ -244,34 +244,38 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick } public getOptions(): EditorOptions { - return EditorOptions.create({}); + return null; } public run(mode: Mode, context: IEntryRunContext): boolean { - const hideWidget = mode === Mode.OPEN; + const hideWidget = (mode === Mode.OPEN); if (mode === Mode.OPEN || mode === Mode.OPEN_IN_BACKGROUND) { let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; - let opts = this.getOptions(); - let backgroundOpts; + let openInBackgroundOptions: IEditorOptions; if (mode === Mode.OPEN_IN_BACKGROUND) { - backgroundOpts = { pinned: true, preserveFocus: true }; - opts.mixin(backgroundOpts); + openInBackgroundOptions = { pinned: true, preserveFocus: true }; } let input = this.getInput(); if (input instanceof EditorInput) { + let opts = this.getOptions(); + if (opts) { + opts.mixin(openInBackgroundOptions); + } else if (openInBackgroundOptions) { + opts = EditorOptions.create(openInBackgroundOptions); + } + this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError); - } - else { - if (backgroundOpts) { - (input).options = objects.assign( - (input).options || {}, - backgroundOpts - ); + } else { + const resourceInput = input; + + if (openInBackgroundOptions) { + resourceInput.options = objects.assign(resourceInput.options || Object.create(null), openInBackgroundOptions); } - this.editorService.openEditor(input, sideBySide).done(null, errors.onUnexpectedError); + + this.editorService.openEditor(resourceInput, sideBySide).done(null, errors.onUnexpectedError); } } @@ -431,4 +435,4 @@ export class QuickOpenAction extends Action { return TPromise.as(null); } -} +} \ No newline at end of file diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index a5fef85c2f62bf42a6358f9db077776722c8f48a..0213f07caecb23679c09fcf295caf0713b309b7a 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -454,12 +454,15 @@ export class EditorOptions implements IEditorOptions { /** * Inherit all options from other EditorOptions instance. */ - public mixin(other: EditorOptions): void { - this.preserveFocus = other.preserveFocus; - this.forceOpen = other.forceOpen; - this.revealIfVisible = other.revealIfVisible; - this.pinned = other.pinned; - this.index = other.index; + public mixin(other: IEditorOptions): void { + if (other) { + this.preserveFocus = other.preserveFocus; + this.forceOpen = other.forceOpen; + this.revealIfVisible = other.revealIfVisible; + this.pinned = other.pinned; + this.index = other.index; + this.inactive = other.inactive; + } } /**