提交 e8e3e355 编写于 作者: W Will Prater

quick open files in background

- allows one to continually open files while keeping quick open widget focused
- uses the right modifier key to open in background
- can open in split view if using the cmd trigger key
上级 b23229f6
......@@ -166,12 +166,12 @@ export class QuickOpenWidget implements IModelProvider {
}
// Select element on Enter
else if (keyboardEvent.keyCode === KeyCode.Enter) {
else if (keyboardEvent.keyCode === KeyCode.Enter || keyboardEvent.keyCode === KeyCode.RightArrow) {
DOM.EventHelper.stop(e, true);
const focus = this.tree.getFocus();
if (focus) {
this.elementSelected(focus, e);
this.elementSelected(focus, keyboardEvent);
}
}
......@@ -406,8 +406,20 @@ export class QuickOpenWidget implements IModelProvider {
// Trigger open of element on selection
if (this.isVisible()) {
const context: IEntryRunContext = { event, keymods: this.extractKeyMods(event), quickNavigateConfiguration: this.quickNavigateConfiguration };
hide = this.model.runner.run(value, Mode.OPEN, context);
let eventForContext = event;
let mode = 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 };
hide = this.model.runner.run(value, mode, context);
}
// add telemetry when an item is accepted, logging the index of the item in the list and the length of the list
......
......@@ -43,7 +43,8 @@ export interface IAutoFocus {
export enum Mode {
PREVIEW,
OPEN
OPEN,
OPEN_IN_BACKGROUND
}
export interface IEntryRunContext {
......
......@@ -1116,7 +1116,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
return true;
}
return false;
return super.run(mode, context);
}
}
......
......@@ -6,6 +6,7 @@
import nls = require('vs/nls');
import { TPromise } from 'vs/base/common/winjs.base';
import * as objects from 'vs/base/common/objects';
import filters = require('vs/base/common/filters');
import arrays = require('vs/base/common/arrays');
import strings = require('vs/base/common/strings');
......@@ -243,24 +244,38 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick
}
public getOptions(): EditorOptions {
return null;
return EditorOptions.create({});
}
public run(mode: Mode, context: IEntryRunContext): boolean {
if (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;
if (mode === Mode.OPEN_IN_BACKGROUND) {
backgroundOpts = { pinned: true, preserveFocus: true };
opts.mixin(backgroundOpts);
}
let input = this.getInput();
if (input instanceof EditorInput) {
this.editorService.openEditor(input, this.getOptions(), sideBySide).done(null, errors.onUnexpectedError);
} else {
this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError);
}
else {
if (backgroundOpts) {
(<IResourceInput>input).options = objects.assign(
(<IResourceInput>input).options || {},
backgroundOpts
);
}
this.editorService.openEditor(<IResourceInput>input, sideBySide).done(null, errors.onUnexpectedError);
}
return true;
}
return false;
return hideWidget;
}
}
......@@ -416,4 +431,4 @@ export class QuickOpenAction extends Action {
return TPromise.as(null);
}
}
\ No newline at end of file
}
......@@ -79,7 +79,8 @@ class SymbolEntry extends EditorQuickOpenEntry {
.then(_ => super.run(mode, context))
.done(undefined, onUnexpectedError);
return true;
// hide if OPEN
return mode === Mode.OPEN;
}
public getInput(): IResourceInput | EditorInput {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册