提交 89fbdde4 编写于 作者: B Benjamin Pasero
上级 1d59084d
...@@ -171,7 +171,7 @@ export class QuickOpenWidget implements IModelProvider { ...@@ -171,7 +171,7 @@ export class QuickOpenWidget implements IModelProvider {
const focus = this.tree.getFocus(); const focus = this.tree.getFocus();
if (focus) { 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 { ...@@ -401,23 +401,14 @@ export class QuickOpenWidget implements IModelProvider {
this.model.runner.run(value, Mode.PREVIEW, context); 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; let hide = true;
// Trigger open of element on selection // Trigger open of element on selection
if (this.isVisible()) { if (this.isVisible()) {
let eventForContext = event; let mode = preferredMode || Mode.OPEN;
let mode = Mode.OPEN;
if (event instanceof StandardKeyboardEvent) { const context: IEntryRunContext = { event, keymods: this.extractKeyMods(event), quickNavigateConfiguration: this.quickNavigateConfiguration };
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 };
hide = this.model.runner.run(value, mode, context); hide = this.model.runner.run(value, mode, context);
} }
......
...@@ -18,7 +18,7 @@ import { KeyMod } from 'vs/base/common/keyCodes'; ...@@ -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 { 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 { QuickOpenEntry, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { EditorOptions, EditorInput } from 'vs/workbench/common/editor'; 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 { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
...@@ -244,34 +244,38 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick ...@@ -244,34 +244,38 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick
} }
public getOptions(): EditorOptions { public getOptions(): EditorOptions {
return EditorOptions.create({}); return null;
} }
public run(mode: Mode, context: IEntryRunContext): boolean { 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) { if (mode === Mode.OPEN || mode === Mode.OPEN_IN_BACKGROUND) {
let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0;
let opts = this.getOptions();
let backgroundOpts; let openInBackgroundOptions: IEditorOptions;
if (mode === Mode.OPEN_IN_BACKGROUND) { if (mode === Mode.OPEN_IN_BACKGROUND) {
backgroundOpts = { pinned: true, preserveFocus: true }; openInBackgroundOptions = { pinned: true, preserveFocus: true };
opts.mixin(backgroundOpts);
} }
let input = this.getInput(); let input = this.getInput();
if (input instanceof EditorInput) { 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); this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError);
} } else {
else { const resourceInput = <IResourceInput>input;
if (backgroundOpts) {
(<IResourceInput>input).options = objects.assign( if (openInBackgroundOptions) {
(<IResourceInput>input).options || {}, resourceInput.options = objects.assign(resourceInput.options || Object.create(null), openInBackgroundOptions);
backgroundOpts
);
} }
this.editorService.openEditor(<IResourceInput>input, sideBySide).done(null, errors.onUnexpectedError);
this.editorService.openEditor(resourceInput, sideBySide).done(null, errors.onUnexpectedError);
} }
} }
...@@ -431,4 +435,4 @@ export class QuickOpenAction extends Action { ...@@ -431,4 +435,4 @@ export class QuickOpenAction extends Action {
return TPromise.as(null); return TPromise.as(null);
} }
} }
\ No newline at end of file
...@@ -454,12 +454,15 @@ export class EditorOptions implements IEditorOptions { ...@@ -454,12 +454,15 @@ export class EditorOptions implements IEditorOptions {
/** /**
* Inherit all options from other EditorOptions instance. * Inherit all options from other EditorOptions instance.
*/ */
public mixin(other: EditorOptions): void { public mixin(other: IEditorOptions): void {
this.preserveFocus = other.preserveFocus; if (other) {
this.forceOpen = other.forceOpen; this.preserveFocus = other.preserveFocus;
this.revealIfVisible = other.revealIfVisible; this.forceOpen = other.forceOpen;
this.pinned = other.pinned; this.revealIfVisible = other.revealIfVisible;
this.index = other.index; this.pinned = other.pinned;
this.index = other.index;
this.inactive = other.inactive;
}
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册