From 89fbdde423f27e272f402998316cf3950d878453 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 21 Oct 2016 09:01:57 +0200 Subject: [PATCH] clean up from https://github.com/Microsoft/vscode/pull/13925 --- .../quickopen/browser/quickOpenWidget.ts | 17 +++------ src/vs/workbench/browser/quickopen.ts | 36 ++++++++++--------- src/vs/workbench/common/editor.ts | 15 ++++---- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts b/src/vs/base/parts/quickopen/browser/quickOpenWidget.ts index cc3c2d2bc2c..6bfa095377b 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 3713a0057a4..fae478e3de5 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 a5fef85c2f6..0213f07caec 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; + } } /** -- GitLab