提交 89fbdde4 编写于 作者: B Benjamin Pasero
上级 1d59084d
......@@ -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);
}
......
......@@ -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) {
(<IResourceInput>input).options = objects.assign(
(<IResourceInput>input).options || {},
backgroundOpts
);
} else {
const resourceInput = <IResourceInput>input;
if (openInBackgroundOptions) {
resourceInput.options = objects.assign(resourceInput.options || Object.create(null), openInBackgroundOptions);
}
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 {
return TPromise.as(null);
}
}
}
\ No newline at end of file
......@@ -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;
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册