From 89f823f991afbd25cf14ed79882db206226ec0b9 Mon Sep 17 00:00:00 2001 From: Will Prater Date: Mon, 17 Oct 2016 13:58:48 -0700 Subject: [PATCH 01/12] eagerly preview quickOpen and picker editors while selecting - editorPicker has position and will show editors as they are selected - quickOpen will preview editor in a `preview editor` - focus is preserved to to keep the quickOpen around while selecting - https://github.com/Microsoft/vscode/issues/8939#issuecomment-234067516 - https://github.com/Microsoft/vscode/issues/8939#issuecomment-254443250 --- src/vs/platform/editor/common/editor.ts | 7 +++ .../browser/parts/editor/editorPart.ts | 13 ++++- .../browser/parts/editor/editorPicker.ts | 21 ++++--- .../parts/quickopen/quickOpenController.ts | 57 +++++++++++++++++-- src/vs/workbench/browser/quickopen.ts | 49 +++++++++------- src/vs/workbench/common/editor.ts | 18 +++++- .../services/history/browser/history.ts | 23 ++++++-- .../services/history/common/history.ts | 7 ++- 8 files changed, 153 insertions(+), 42 deletions(-) diff --git a/src/vs/platform/editor/common/editor.ts b/src/vs/platform/editor/common/editor.ts index 2bebb45e399e4..2edb4faba21fe 100644 --- a/src/vs/platform/editor/common/editor.ts +++ b/src/vs/platform/editor/common/editor.ts @@ -179,6 +179,13 @@ export interface IEditorOptions { */ pinned?: boolean; + /** + * Editor that is being shown with an `forcePreview` will override the `enablePreview` setting + * of the workspace configuration to allow the editor to be shown as a preview editor while + * selecting in the quick open widgets. + */ + forcePreview?: boolean; + /** * The index in the document stack where to insert the editor into when opening. */ diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 39f47cce016ff..02394158d98ec 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -239,7 +239,16 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService // while the UI is not yet ready. Clients have to deal with this fact and we have to make sure that the // stacks model gets updated if any of the UI updating fails with an error. const group = this.ensureGroup(position, !options || !options.preserveFocus); - const pinned = !this.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty(); + let pinned = !this.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty(); + if (this.previewEditors && options && !options.pinned) { + pinned = !this.configurationService.getConfiguration().workbench.editor.enablePreviewFromQuickOpen; + } + if (options && options.forcePreview) { + pinned = false; + options.pinned = pinned; + options.revealIfVisible = true; + options.preserveFocus = true; + } const active = (group.count === 0) || !options || !options.inactive; group.openEditor(input, { active, pinned, index: options && options.index }); @@ -1380,4 +1389,4 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService private hasGroup(position: Position): boolean { return !!this.stacks.groupAt(position); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/browser/parts/editor/editorPicker.ts b/src/vs/workbench/browser/parts/editor/editorPicker.ts index 4cec36daa7f70..2b3b58058412b 100644 --- a/src/vs/workbench/browser/parts/editor/editorPicker.ts +++ b/src/vs/workbench/browser/parts/editor/editorPicker.ts @@ -19,13 +19,14 @@ import { IModeService } from 'vs/editor/common/services/modeService'; import { getIconClasses } from 'vs/workbench/browser/labels'; import { IModelService } from 'vs/editor/common/services/modelService'; import { QuickOpenHandler } from 'vs/workbench/browser/quickopen'; -import { Position } from 'vs/platform/editor/common/editor'; +import { IEditorOptions, ITextEditorOptions, Position } from 'vs/platform/editor/common/editor'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { EditorInput, asFileEditorInput, IEditorGroup, IEditorStacksModel } from 'vs/workbench/common/editor'; + export class EditorPickerEntry extends QuickOpenEntryGroup { private stacks: IEditorStacksModel; @@ -77,16 +78,22 @@ export class EditorPickerEntry extends QuickOpenEntryGroup { public run(mode: Mode, context: IEntryRunContext): boolean { if (mode === Mode.OPEN) { - return this.runOpen(context); + this.runOpen(context); + + return true; + } + else if (mode === Mode.PREVIEW) { + this.runOpen(context, { forcePreview: true }); + + return false; } return super.run(mode, context); } - private runOpen(context: IEntryRunContext): boolean { - this.editorService.openEditor(this.editor, null, this.stacks.positionOfGroup(this.group)).done(null, errors.onUnexpectedError); - - return true; + private runOpen(context: IEntryRunContext, options?: IEditorOptions | ITextEditorOptions) { + this.editorService.openEditor(this.editor, options, this.stacks.positionOfGroup(this.group)) + .done(null, errors.onUnexpectedError); } } @@ -267,4 +274,4 @@ export class AllEditorsPicker extends BaseEditorPicker { return super.getAutoFocus(searchValue); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index b35417330c7f6..9c1ef9fc09747 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -46,6 +46,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IContextKeyService, RawContextKey, IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; +import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; const HELP_PREFIX = '?'; const QUICK_OPEN_MODE = new RawContextKey('inQuickOpen', false); @@ -94,6 +95,8 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe private previousActiveHandlerDescriptor: QuickOpenHandlerDescriptor; private actionProvider = new ContributableActionProvider(); private previousValue = ''; + private previousActiveEditorInput: IEditorInput; + private previousPreviewEditorInput: IEditorInput; private visibilityChangeTimeoutHandle: number; private closeOnFocusLost: boolean; @@ -106,7 +109,8 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe @IConfigurationService private configurationService: IConfigurationService, @IHistoryService private historyService: IHistoryService, @IInstantiationService private instantiationService: IInstantiationService, - @IPartService private partService: IPartService + @IPartService private partService: IPartService, + @IEditorGroupService private editorGroupService: IEditorGroupService ) { super(QuickOpenController.ID); @@ -267,7 +271,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe withElementById(this.partService.getWorkbenchElementId()).getHTMLElement(), { onOk: () => { /* ignore, handle later */ }, - onCancel: () => { /* ignore, handle later */ }, + onCancel: () => this.handleOnCancel(true), onType: (value: string) => { /* ignore, handle later */ }, onShow: () => this.handleOnShow(true), onHide: (reason) => this.handleOnHide(true, reason) @@ -479,6 +483,21 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe this.previousValue = prefix; + // Track active editor before navigation + this.previousActiveEditorInput = this.editorService.getActiveEditorInput(); + + // Determine if there was a preview editor already open + this.previousPreviewEditorInput = null; + const activeGroup = this.editorGroupService.getStacksModel().activeGroup; + if (activeGroup) { + const visiblePreviewEditors = activeGroup.getEditors().filter((input: EditorInput) => { + return activeGroup.isPreview(input); + }); + if (visiblePreviewEditors.length) { + this.previousPreviewEditorInput = visiblePreviewEditors[0]; + } + } + const promiseCompletedOnHide = new TPromise(c => { this.promisesToCompleteOnHide.push(c); }); @@ -499,7 +518,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe withElementById(this.partService.getWorkbenchElementId()).getHTMLElement(), { onOk: () => { /* ignore */ }, - onCancel: () => { /* ignore */ }, + onCancel: () => this.handleOnCancel(false), onType: (value: string) => this.onType(value || ''), onShow: () => this.handleOnShow(false), onHide: (reason) => this.handleOnHide(false, reason), @@ -549,6 +568,33 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe return promiseCompletedOnHide; } + private handleOnCancel(isPicker: boolean): void { + // restore the editor part state after cancelling + this.historyService.block(true); + + // restore the previous preview editor + if (this.previousPreviewEditorInput) { + this.editorService.openEditor(this.previousPreviewEditorInput, { preserveFocus: true }); + } + // otherwise close the preview editor that was created with eager preview + else { + const activeGroup = this.editorGroupService.getStacksModel().activeGroup; + const groupPosition = this.editorGroupService.getStacksModel().positionOfGroup(activeGroup); + if (activeGroup.previewEditor) { + this.editorService.closeEditor(groupPosition, activeGroup.previewEditor); + } + } + + // restore the prevously active tab + this.editorService.openEditor(this.previousActiveEditorInput).done( + () => this.historyService.block(false), + err => { + this.historyService.block(false); + errors.onUnexpectedError(err); + } + ); + } + private handleOnShow(isPicker: boolean): void { if (isPicker && this.quickOpenWidget) { this.quickOpenWidget.hide(HideReason.FOCUS_LOST); @@ -1115,6 +1161,9 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { return true; } + else if (mode === Mode.PREVIEW) { + return super.run(mode, context); + } return super.run(mode, context); } @@ -1158,4 +1207,4 @@ export class RemoveFromEditorHistoryAction extends Action { } }); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index fae478e3de578..fbb2430636bdc 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -250,33 +250,38 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick public run(mode: Mode, context: IEntryRunContext): boolean { const hideWidget = (mode === Mode.OPEN); + let sideBySide; if (mode === Mode.OPEN || mode === Mode.OPEN_IN_BACKGROUND) { - let sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; - - let openInBackgroundOptions: IEditorOptions; - if (mode === Mode.OPEN_IN_BACKGROUND) { - openInBackgroundOptions = { pinned: true, preserveFocus: true }; - } + sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; + } - let input = this.getInput(); - if (input instanceof EditorInput) { - let opts = this.getOptions(); - if (opts) { - opts.mixin(openInBackgroundOptions); - } else if (openInBackgroundOptions) { - opts = EditorOptions.create(openInBackgroundOptions); - } + let modeOverrideOptions: IEditorOptions; + if (mode === Mode.PREVIEW) { + modeOverrideOptions = { forcePreview: true }; + } + else if (mode === Mode.OPEN_IN_BACKGROUND) { + modeOverrideOptions = { forcePreview: false, pinned: true, preserveFocus: true }; + } - this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError); - } else { - const resourceInput = input; + let input = this.getInput(); + if (input instanceof EditorInput) { + let opts = this.getOptions(); + if (opts) { + opts.mixin(modeOverrideOptions); + } else if (modeOverrideOptions) { + opts = EditorOptions.create(modeOverrideOptions); + } - if (openInBackgroundOptions) { - resourceInput.options = objects.assign(resourceInput.options || Object.create(null), openInBackgroundOptions); - } + this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError); + } + else { + const resourceInput = input; - this.editorService.openEditor(resourceInput, sideBySide).done(null, errors.onUnexpectedError); + if (modeOverrideOptions) { + resourceInput.options = objects.assign(resourceInput.options || Object.create(null), modeOverrideOptions); } + + this.editorService.openEditor(resourceInput, sideBySide).done(null, errors.onUnexpectedError); } return hideWidget; @@ -435,4 +440,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 7a549008eca29..65b94f60a7cb5 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -440,6 +440,7 @@ export class EditorOptions implements IEditorOptions { options.forceOpen = settings.forceOpen; options.revealIfVisible = settings.revealIfVisible; options.pinned = settings.pinned; + options.forcePreview = settings.forcePreview; options.index = settings.index; options.inactive = settings.inactive; @@ -455,6 +456,7 @@ export class EditorOptions implements IEditorOptions { this.forceOpen = other.forceOpen; this.revealIfVisible = other.revealIfVisible; this.pinned = other.pinned; + this.forcePreview = other.forcePreview; this.index = other.index; this.inactive = other.inactive; } @@ -484,6 +486,13 @@ export class EditorOptions implements IEditorOptions { */ public pinned: boolean; + /** + * Editor that is being shown with an `forcePreview` will override the `enablePreview` setting + * of the workspace configuration to allow the editor to be shown as a preview editor while + * selecting in the quick open widgets. + */ + public forcePreview: boolean; + /** * The index in the document stack where to insert the editor into when opening. */ @@ -511,7 +520,7 @@ export class TextEditorOptions extends EditorOptions { public static from(input: IResourceInput): TextEditorOptions { let options: TextEditorOptions = null; if (input && input.options) { - if (input.options.selection || input.options.forceOpen || input.options.revealIfVisible || input.options.preserveFocus || input.options.pinned || input.options.inactive || typeof input.options.index === 'number') { + if (input.options.selection || input.options.forceOpen || input.options.revealIfVisible || input.options.preserveFocus || input.options.pinned || input.options.forcePreview || input.options.inactive || typeof input.options.index === 'number') { options = new TextEditorOptions(); } @@ -536,6 +545,10 @@ export class TextEditorOptions extends EditorOptions { options.pinned = true; } + if (input.options.forcePreview) { + options.forcePreview = true; + } + if (input.options.inactive) { options.inactive = true; } @@ -557,6 +570,7 @@ export class TextEditorOptions extends EditorOptions { options.forceOpen = settings.forceOpen; options.revealIfVisible = settings.revealIfVisible; options.pinned = settings.pinned; + options.forcePreview = settings.forcePreview; options.index = settings.index; if (settings.selection) { @@ -888,4 +902,4 @@ export interface ActiveEditorMoveArguments { export var EditorCommands = { MoveActiveEditor: 'moveActiveEditor' -}; \ No newline at end of file +}; diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 84ac57a6ad1de..c093ec13c8bed 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -119,7 +119,6 @@ export abstract class BaseHistoryService { const activeEditor = this.editorService.getActiveEditor(); const activeInput = activeEditor ? activeEditor.input : void 0; - // Propagate to history this.onEditorEvent(activeEditor); // Apply listener for dirty and label changes @@ -248,6 +247,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic private stack: IStackEntry[]; private index: number; private blockStackChanges: boolean; + private blockEditorHistoryChanges: boolean; private currentFileEditorState: EditorState; private history: (IEditorInput | IResourceInput)[]; @@ -339,6 +339,17 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic this.recentlyClosedFiles = []; } + public block(block: boolean) { + if (block) { + this.blockStackChanges = true; + this.blockEditorHistoryChanges = true; + } + else { + this.blockStackChanges = false; + this.blockEditorHistoryChanges = false; + } + } + private navigate(): void { const entry = this.stack[this.index]; @@ -379,7 +390,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic const input = editor ? editor.input : void 0; // Ensure we have at least a name to show - if (!input || !input.getName()) { + if (this.blockEditorHistoryChanges || this.isEditorEagerlyPreviewing(editor) || !input || !input.getName()) { return; } @@ -424,6 +435,10 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic } } + private isEditorEagerlyPreviewing(editor: IBaseEditor): boolean { + return !!(editor && editor.options && editor.options.forcePreview); + } + private indexOf(input: IEditorInput | IResourceInput): number { for (let i = 0; i < this.history.length; i++) { const entry = this.history[i]; @@ -436,7 +451,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic } private handleEditorEventInStack(editor: IBaseEditor, storeSelection: boolean): void { - if (this.blockStackChanges) { + if (this.blockStackChanges || this.isEditorEagerlyPreviewing(editor)) { return; // while we open an editor due to a navigation, we do not want to update our stack } @@ -692,4 +707,4 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic return void 0; }).filter(input => !!input); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/services/history/common/history.ts b/src/vs/workbench/services/history/common/history.ts index d76384abd5c99..1f91345845144 100644 --- a/src/vs/workbench/services/history/common/history.ts +++ b/src/vs/workbench/services/history/common/history.ts @@ -47,4 +47,9 @@ export interface IHistoryService { * Get the entire history of opened editors. */ getHistory(): (IEditorInput | IResourceInput)[]; -} \ No newline at end of file + + /** + * Blocks writing to stack and editor history. + */ + block(block: boolean): void; +} From 18f4f3e6762d9fb0443caa221f35677de2c094ad Mon Sep 17 00:00:00 2001 From: Will Prater Date: Fri, 21 Oct 2016 09:15:13 -0700 Subject: [PATCH 02/12] style fixes --- src/vs/workbench/browser/parts/editor/editorPicker.ts | 3 +-- src/vs/workbench/browser/quickopen.ts | 6 ++---- src/vs/workbench/services/history/browser/history.ts | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editorPicker.ts b/src/vs/workbench/browser/parts/editor/editorPicker.ts index 2b3b58058412b..4141e33c9dd02 100644 --- a/src/vs/workbench/browser/parts/editor/editorPicker.ts +++ b/src/vs/workbench/browser/parts/editor/editorPicker.ts @@ -81,8 +81,7 @@ export class EditorPickerEntry extends QuickOpenEntryGroup { this.runOpen(context); return true; - } - else if (mode === Mode.PREVIEW) { + } else if (mode === Mode.PREVIEW) { this.runOpen(context, { forcePreview: true }); return false; diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index fbb2430636bdc..153044398ecb2 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -258,8 +258,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick let modeOverrideOptions: IEditorOptions; if (mode === Mode.PREVIEW) { modeOverrideOptions = { forcePreview: true }; - } - else if (mode === Mode.OPEN_IN_BACKGROUND) { + } else if (mode === Mode.OPEN_IN_BACKGROUND) { modeOverrideOptions = { forcePreview: false, pinned: true, preserveFocus: true }; } @@ -273,8 +272,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick } this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError); - } - else { + } else { const resourceInput = input; if (modeOverrideOptions) { diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index c093ec13c8bed..efe968a17f9da 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -343,8 +343,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic if (block) { this.blockStackChanges = true; this.blockEditorHistoryChanges = true; - } - else { + } else { this.blockStackChanges = false; this.blockEditorHistoryChanges = false; } From 78cad07242d59be18c13226cc9bf3579c2174491 Mon Sep 17 00:00:00 2001 From: Will Prater Date: Fri, 21 Oct 2016 09:23:51 -0700 Subject: [PATCH 03/12] explicitly pass in options needed during eager previewing --- src/vs/workbench/browser/parts/editor/editorPart.ts | 11 +---------- src/vs/workbench/browser/parts/editor/editorPicker.ts | 2 +- src/vs/workbench/browser/quickopen.ts | 4 ++-- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 02394158d98ec..ae9a82cf044b2 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -239,16 +239,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService // while the UI is not yet ready. Clients have to deal with this fact and we have to make sure that the // stacks model gets updated if any of the UI updating fails with an error. const group = this.ensureGroup(position, !options || !options.preserveFocus); - let pinned = !this.previewEditors || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty(); - if (this.previewEditors && options && !options.pinned) { - pinned = !this.configurationService.getConfiguration().workbench.editor.enablePreviewFromQuickOpen; - } - if (options && options.forcePreview) { - pinned = false; - options.pinned = pinned; - options.revealIfVisible = true; - options.preserveFocus = true; - } + const pinned = (!this.previewEditors && !(options && options.forcePreview)) || (options && (options.pinned || typeof options.index === 'number')) || input.isDirty(); const active = (group.count === 0) || !options || !options.inactive; group.openEditor(input, { active, pinned, index: options && options.index }); diff --git a/src/vs/workbench/browser/parts/editor/editorPicker.ts b/src/vs/workbench/browser/parts/editor/editorPicker.ts index 4141e33c9dd02..f051b12c9bcb2 100644 --- a/src/vs/workbench/browser/parts/editor/editorPicker.ts +++ b/src/vs/workbench/browser/parts/editor/editorPicker.ts @@ -82,7 +82,7 @@ export class EditorPickerEntry extends QuickOpenEntryGroup { return true; } else if (mode === Mode.PREVIEW) { - this.runOpen(context, { forcePreview: true }); + this.runOpen(context, { forcePreview: true, pinned: false, revealIfVisible: true, preserveFocus: true }); return false; } diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 153044398ecb2..d0d0847695efe 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -257,9 +257,9 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick let modeOverrideOptions: IEditorOptions; if (mode === Mode.PREVIEW) { - modeOverrideOptions = { forcePreview: true }; + modeOverrideOptions = { forcePreview: true, pinned: false, revealIfVisible: true, preserveFocus: true }; } else if (mode === Mode.OPEN_IN_BACKGROUND) { - modeOverrideOptions = { forcePreview: false, pinned: true, preserveFocus: true }; + modeOverrideOptions = { pinned: true, preserveFocus: true }; } let input = this.getInput(); From 070673ffbbfc386a4c82cea64365eee011c532ec Mon Sep 17 00:00:00 2001 From: Will Prater Date: Fri, 21 Oct 2016 09:23:59 -0700 Subject: [PATCH 04/12] cleanup --- src/vs/platform/editor/common/editor.ts | 5 ++--- .../browser/parts/quickopen/quickOpenController.ts | 14 ++++---------- .../workbench/services/history/browser/history.ts | 1 + 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/vs/platform/editor/common/editor.ts b/src/vs/platform/editor/common/editor.ts index 2edb4faba21fe..10b9bca6ef7aa 100644 --- a/src/vs/platform/editor/common/editor.ts +++ b/src/vs/platform/editor/common/editor.ts @@ -181,8 +181,7 @@ export interface IEditorOptions { /** * Editor that is being shown with an `forcePreview` will override the `enablePreview` setting - * of the workspace configuration to allow the editor to be shown as a preview editor while - * selecting in the quick open widgets. + * of the workspace configuration to allow the editor to be shown as a preview editor. */ forcePreview?: boolean; @@ -209,4 +208,4 @@ export interface ITextEditorOptions extends IEditorOptions { endLineNumber?: number; endColumn?: number; }; -} \ No newline at end of file +} diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 9c1ef9fc09747..5d48784c55a38 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -484,18 +484,12 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe this.previousValue = prefix; // Track active editor before navigation - this.previousActiveEditorInput = this.editorService.getActiveEditorInput(); + const activeGroup = this.editorGroupService.getStacksModel().activeGroup; // Determine if there was a preview editor already open - this.previousPreviewEditorInput = null; - const activeGroup = this.editorGroupService.getStacksModel().activeGroup; if (activeGroup) { - const visiblePreviewEditors = activeGroup.getEditors().filter((input: EditorInput) => { - return activeGroup.isPreview(input); - }); - if (visiblePreviewEditors.length) { - this.previousPreviewEditorInput = visiblePreviewEditors[0]; - } + this.previousActiveEditorInput = activeGroup.activeEditor; + this.previousPreviewEditorInput = activeGroup.previewEditor; } const promiseCompletedOnHide = new TPromise(c => { @@ -580,7 +574,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe else { const activeGroup = this.editorGroupService.getStacksModel().activeGroup; const groupPosition = this.editorGroupService.getStacksModel().positionOfGroup(activeGroup); - if (activeGroup.previewEditor) { + if (activeGroup && activeGroup.previewEditor) { this.editorService.closeEditor(groupPosition, activeGroup.previewEditor); } } diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index efe968a17f9da..5c06e6cf929a7 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -119,6 +119,7 @@ export abstract class BaseHistoryService { const activeEditor = this.editorService.getActiveEditor(); const activeInput = activeEditor ? activeEditor.input : void 0; + // Propagate to history this.onEditorEvent(activeEditor); // Apply listener for dirty and label changes From 7e518781ba762cd4549f05e7bb2682488ec9e6ec Mon Sep 17 00:00:00 2001 From: Will Prater Date: Sun, 23 Oct 2016 18:15:06 -0700 Subject: [PATCH 05/12] remove isEditorEagerlyPreviewing from history - will only rely on the block properties --- src/vs/workbench/services/history/browser/history.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index 5c06e6cf929a7..777c03af5f0be 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -390,7 +390,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic const input = editor ? editor.input : void 0; // Ensure we have at least a name to show - if (this.blockEditorHistoryChanges || this.isEditorEagerlyPreviewing(editor) || !input || !input.getName()) { + if (this.blockEditorHistoryChanges || !input || !input.getName()) { return; } @@ -435,10 +435,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic } } - private isEditorEagerlyPreviewing(editor: IBaseEditor): boolean { - return !!(editor && editor.options && editor.options.forcePreview); - } - private indexOf(input: IEditorInput | IResourceInput): number { for (let i = 0; i < this.history.length; i++) { const entry = this.history[i]; @@ -451,7 +447,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic } private handleEditorEventInStack(editor: IBaseEditor, storeSelection: boolean): void { - if (this.blockStackChanges || this.isEditorEagerlyPreviewing(editor)) { + if (this.blockStackChanges) { return; // while we open an editor due to a navigation, we do not want to update our stack } From 03a9f64ac83a6fae8765470b7341e5a0ad64871e Mon Sep 17 00:00:00 2001 From: Will Prater Date: Sun, 23 Oct 2016 18:16:53 -0700 Subject: [PATCH 06/12] block history when previewing from editor picker --- src/vs/workbench/browser/parts/editor/editorPicker.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/browser/parts/editor/editorPicker.ts b/src/vs/workbench/browser/parts/editor/editorPicker.ts index f051b12c9bcb2..f74843a68750a 100644 --- a/src/vs/workbench/browser/parts/editor/editorPicker.ts +++ b/src/vs/workbench/browser/parts/editor/editorPicker.ts @@ -16,6 +16,7 @@ import { IAutoFocus, Mode, IEntryRunContext, IQuickNavigateConfiguration } from import { QuickOpenModel, QuickOpenEntry, QuickOpenEntryGroup } from 'vs/base/parts/quickopen/browser/quickOpenModel'; import scorer = require('vs/base/common/scorer'); import { IModeService } from 'vs/editor/common/services/modeService'; +import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { getIconClasses } from 'vs/workbench/browser/labels'; import { IModelService } from 'vs/editor/common/services/modelService'; import { QuickOpenHandler } from 'vs/workbench/browser/quickopen'; @@ -36,6 +37,7 @@ export class EditorPickerEntry extends QuickOpenEntryGroup { @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IModeService private modeService: IModeService, @IModelService private modelService: IModelService, + @IHistoryService protected historyService: IHistoryService, @IEditorGroupService editorGroupService: IEditorGroupService ) { super(); @@ -91,8 +93,14 @@ export class EditorPickerEntry extends QuickOpenEntryGroup { } private runOpen(context: IEntryRunContext, options?: IEditorOptions | ITextEditorOptions) { + if (options.forcePreview) { + this.historyService.block(true); + } this.editorService.openEditor(this.editor, options, this.stacks.positionOfGroup(this.group)) - .done(null, errors.onUnexpectedError); + .done(() => this.historyService.block(false), err => { + this.historyService.block(false); + errors.onUnexpectedError(err); + }); } } From afa91e03c250787ac9a6be53496621ceb79cd60e Mon Sep 17 00:00:00 2001 From: Will Prater Date: Tue, 25 Oct 2016 14:20:42 -0700 Subject: [PATCH 07/12] all abstract classes of `EditorQuickOpenEntry` should pass a history service --- .../parts/quickopen/quickOpenController.ts | 3 ++- src/vs/workbench/browser/quickopen.ts | 3 ++- .../parts/quickopen/browser/gotoLineHandler.ts | 16 ++++++++++++---- .../parts/search/browser/openFileHandler.ts | 2 +- .../parts/search/browser/openSymbolHandler.ts | 8 +++++--- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 5d48784c55a38..418be0e4b48dc 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -1088,9 +1088,10 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { @IModelService private modelService: IModelService, @ITextFileService private textFileService: ITextFileService, @IWorkspaceContextService contextService: IWorkspaceContextService, + @IHistoryService private historyService: IHistoryService, @IConfigurationService private configurationService: IConfigurationService ) { - super(editorService); + super(editorService, historyService); this.input = input; diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index d0d0847695efe..32bf91dd47cba 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -20,6 +20,7 @@ import { QuickOpenEntry, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from import { EditorOptions, EditorInput } from 'vs/workbench/common/editor'; import { IResourceInput, IEditorInput, IEditorOptions } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; @@ -231,7 +232,7 @@ export interface IEditorQuickOpenEntry { */ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuickOpenEntry { - constructor(private _editorService: IWorkbenchEditorService) { + constructor(private _editorService: IWorkbenchEditorService, private _historyService: IHistoryService) { super(); } diff --git a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts index d8d424b96eed9..7d24d4fed057d 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts @@ -18,6 +18,8 @@ import { IEditor, IModelDecorationsChangeAccessor, OverviewRulerLane, IModelDelt import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { Position, IEditorInput } from 'vs/platform/editor/common/editor'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IHistoryService } from 'vs/workbench/services/history/common/history'; export const GOTO_LINE_PREFIX = ':'; @@ -36,8 +38,8 @@ class GotoLineEntry extends EditorQuickOpenEntry { private column: number; private handler: GotoLineHandler; - constructor(line: string, editorService: IWorkbenchEditorService, handler: GotoLineHandler) { - super(editorService); + constructor(line: string, editorService: IWorkbenchEditorService, historyService: IHistoryService, handler: GotoLineHandler) { + super(editorService, historyService); this.parseInput(line); this.handler = handler; @@ -170,7 +172,11 @@ export class GotoLineHandler extends QuickOpenHandler { private rangeHighlightDecorationId: IEditorLineDecoration; private lastKnownEditorViewState: IEditorViewState; - constructor( @IWorkbenchEditorService private editorService: IWorkbenchEditorService) { + constructor( + @IWorkbenchEditorService private editorService: IWorkbenchEditorService, + @IInstantiationService private instantiationService: IInstantiationService, + @IHistoryService private historyService: IHistoryService + ) { super(); } @@ -187,7 +193,9 @@ export class GotoLineHandler extends QuickOpenHandler { this.lastKnownEditorViewState = (editor.getControl()).saveViewState(); } - return TPromise.as(new QuickOpenModel([new GotoLineEntry(searchValue, this.editorService, this)])); + const entry = this.instantiationService.createInstance(GotoLineEntry, searchValue, this.editorService, this.historyService, this); + + return TPromise.as(new QuickOpenModel([entry])); } public canRun(): boolean | string { diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 04ca191c83a5e..7478cc42bbc6e 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -295,4 +295,4 @@ export class CacheState { this.previous = null; } } -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts index a4e009ec3bfb7..d7fa9a0765aeb 100644 --- a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts +++ b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts @@ -18,6 +18,7 @@ import { EditorInput, IWorkbenchEditorConfiguration } from 'vs/workbench/common/ import labels = require('vs/base/common/labels'); import { IResourceInput } from 'vs/platform/editor/common/editor'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -32,9 +33,10 @@ class SymbolEntry extends EditorQuickOpenEntry { private _provider: IWorkspaceSymbolProvider, @IConfigurationService private _configurationService: IConfigurationService, @IWorkspaceContextService private _contextService: IWorkspaceContextService, - @IWorkbenchEditorService editorService: IWorkbenchEditorService + @IWorkbenchEditorService editorService: IWorkbenchEditorService, + @IHistoryService private historyService: IHistoryService ) { - super(editorService); + super(editorService, historyService); } public getLabel(): string { @@ -208,4 +210,4 @@ export class OpenSymbolHandler extends QuickOpenHandler { autoFocusPrefixMatch: searchValue.trim() }; } -} \ No newline at end of file +} From 4fedc38d12740cbe2ea271ff0dc1f04325181964 Mon Sep 17 00:00:00 2001 From: Will Prater Date: Tue, 25 Oct 2016 16:15:46 -0700 Subject: [PATCH 08/12] add configuration service to QuickOpenEntry - abstract classes shall pass it --- .../browser/parts/quickopen/quickOpenController.ts | 2 +- src/vs/workbench/browser/quickopen.ts | 6 +++++- .../parts/quickopen/browser/gotoLineHandler.ts | 14 +++++++++----- .../parts/search/browser/openFileHandler.ts | 4 +++- .../parts/search/browser/openSymbolHandler.ts | 6 +++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 418be0e4b48dc..c51ef43fc0903 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -1091,7 +1091,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { @IHistoryService private historyService: IHistoryService, @IConfigurationService private configurationService: IConfigurationService ) { - super(editorService, historyService); + super(editorService, historyService, configurationService); this.input = input; diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 32bf91dd47cba..40e0211c3d801 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -232,7 +232,11 @@ export interface IEditorQuickOpenEntry { */ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuickOpenEntry { - constructor(private _editorService: IWorkbenchEditorService, private _historyService: IHistoryService) { + constructor( + private _editorService: IWorkbenchEditorService, + private _historyService: IHistoryService, + private _configurationService: IConfigurationService + ) { super(); } diff --git a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts index 7d24d4fed057d..801436380bc84 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoLineHandler.ts @@ -20,6 +20,7 @@ import { Position, IEditorInput } from 'vs/platform/editor/common/editor'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export const GOTO_LINE_PREFIX = ':'; @@ -38,8 +39,8 @@ class GotoLineEntry extends EditorQuickOpenEntry { private column: number; private handler: GotoLineHandler; - constructor(line: string, editorService: IWorkbenchEditorService, historyService: IHistoryService, handler: GotoLineHandler) { - super(editorService, historyService); + constructor(line: string, editorService: IWorkbenchEditorService, historyService: IHistoryService, configurationService: IConfigurationService, handler: GotoLineHandler) { + super(editorService, historyService, configurationService); this.parseInput(line); this.handler = handler; @@ -175,7 +176,8 @@ export class GotoLineHandler extends QuickOpenHandler { constructor( @IWorkbenchEditorService private editorService: IWorkbenchEditorService, @IInstantiationService private instantiationService: IInstantiationService, - @IHistoryService private historyService: IHistoryService + @IHistoryService private historyService: IHistoryService, + @IConfigurationService private configurationService: IConfigurationService ) { super(); } @@ -193,7 +195,9 @@ export class GotoLineHandler extends QuickOpenHandler { this.lastKnownEditorViewState = (editor.getControl()).saveViewState(); } - const entry = this.instantiationService.createInstance(GotoLineEntry, searchValue, this.editorService, this.historyService, this); + const entry = this.instantiationService.createInstance( + GotoLineEntry, searchValue, this.editorService, this.historyService, this.configurationService, this + ); return TPromise.as(new QuickOpenModel([entry])); } @@ -289,4 +293,4 @@ export class GotoLineHandler extends QuickOpenHandler { autoFocusFirstEntry: searchValue.trim().length > 0 }; } -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 7478cc42bbc6e..a271fccce0425 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -30,6 +30,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IQueryOptions, ISearchService, ISearchStats, ISearchQuery } from 'vs/platform/search/common/search'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { IHistoryService } from 'vs/workbench/services/history/common/history'; export class FileQuickOpenModel extends QuickOpenModel { @@ -50,9 +51,10 @@ export class FileEntry extends EditorQuickOpenEntry { @IModeService private modeService: IModeService, @IModelService private modelService: IModelService, @IConfigurationService private configurationService: IConfigurationService, + @IHistoryService historyService: IHistoryService, @IWorkspaceContextService contextService: IWorkspaceContextService ) { - super(editorService); + super(editorService, historyService, configurationService); } public getLabel(): string { diff --git a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts index d7fa9a0765aeb..2c1a8b2a88556 100644 --- a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts +++ b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts @@ -31,12 +31,12 @@ class SymbolEntry extends EditorQuickOpenEntry { constructor( private _bearing: IWorkspaceSymbol, private _provider: IWorkspaceSymbolProvider, - @IConfigurationService private _configurationService: IConfigurationService, + @IConfigurationService configurationService: IConfigurationService, @IWorkspaceContextService private _contextService: IWorkspaceContextService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, - @IHistoryService private historyService: IHistoryService + @IHistoryService historyService: IHistoryService ) { - super(editorService, historyService); + super(editorService, historyService, configurationService); } public getLabel(): string { From 09bebf017cb91ecf3b5b9041a2d0ff823be6e4cd Mon Sep 17 00:00:00 2001 From: Will Prater Date: Tue, 25 Oct 2016 16:16:18 -0700 Subject: [PATCH 09/12] refactored into super --- .../parts/quickopen/quickOpenController.ts | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index c51ef43fc0903..541e9ce735618 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -30,11 +30,12 @@ import { IResourceInput, IEditorInput } from 'vs/platform/editor/common/editor'; import { IModeService } from 'vs/editor/common/services/modeService'; import { getIconClasses } from 'vs/workbench/browser/labels'; import { IModelService } from 'vs/editor/common/services/modelService'; -import { EditorInput, getUntitledOrFileResource, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; +// import { EditorInput, getUntitledOrFileResource, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; +import { EditorInput, getUntitledOrFileResource } from 'vs/workbench/common/editor'; import { WorkbenchComponent } from 'vs/workbench/common/component'; import Event, { Emitter } from 'vs/base/common/event'; import { IPartService } from 'vs/workbench/services/part/common/partService'; -import { KeyMod } from 'vs/base/common/keyCodes'; +// import { KeyMod } from 'vs/base/common/keyCodes'; import { QuickOpenHandler, QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions, EditorQuickOpenEntry } from 'vs/workbench/browser/quickopen'; import errors = require('vs/base/common/errors'); import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; @@ -1144,22 +1145,6 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { } public run(mode: Mode, context: IEntryRunContext): boolean { - if (mode === Mode.OPEN) { - const sideBySide = !context.quickNavigateConfiguration && context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; - const pinned = !this.configurationService.getConfiguration().workbench.editor.enablePreviewFromQuickOpen; - - if (this.input instanceof EditorInput) { - this.editorService.openEditor(this.input, { pinned }, sideBySide).done(null, errors.onUnexpectedError); - } else { - this.editorService.openEditor({ resource: (this.input as IResourceInput).resource, options: { pinned } }, sideBySide); - } - - return true; - } - else if (mode === Mode.PREVIEW) { - return super.run(mode, context); - } - return super.run(mode, context); } } From 98cf219515e10561018afa25d80e527a13f70af7 Mon Sep 17 00:00:00 2001 From: Will Prater Date: Tue, 25 Oct 2016 16:16:45 -0700 Subject: [PATCH 10/12] handle history blocking in EditorQuickOpenEntry --- src/vs/workbench/browser/quickopen.ts | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index 40e0211c3d801..81d5d078d92ac 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -17,8 +17,9 @@ import { Action } from 'vs/base/common/actions'; 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, IEditorOptions } from 'vs/platform/editor/common/editor'; +import { EditorOptions, EditorInput, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; +import { IEditor, IResourceInput, IEditorInput, IEditorOptions } from 'vs/platform/editor/common/editor'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService'; @@ -257,16 +258,24 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick let sideBySide; if (mode === Mode.OPEN || mode === Mode.OPEN_IN_BACKGROUND) { - sideBySide = context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; + sideBySide = !context.quickNavigateConfiguration && context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; } + let pinned; let modeOverrideOptions: IEditorOptions; - if (mode === Mode.PREVIEW) { - modeOverrideOptions = { forcePreview: true, pinned: false, revealIfVisible: true, preserveFocus: true }; + if (mode === Mode.OPEN) { + pinned = !this._configurationService.getConfiguration().workbench.editor.enablePreviewFromQuickOpen; + } else if (mode === Mode.PREVIEW) { + pinned = false; + modeOverrideOptions = { forcePreview: true, pinned, revealIfVisible: true, preserveFocus: true }; + + this._historyService.block(true); } else if (mode === Mode.OPEN_IN_BACKGROUND) { - modeOverrideOptions = { pinned: true, preserveFocus: true }; + pinned = true; + modeOverrideOptions = { pinned, preserveFocus: true }; } + let openEditorPromise: TPromise; let input = this.getInput(); if (input instanceof EditorInput) { let opts = this.getOptions(); @@ -276,7 +285,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick opts = EditorOptions.create(modeOverrideOptions); } - this.editorService.openEditor(input, opts, sideBySide).done(null, errors.onUnexpectedError); + openEditorPromise = this.editorService.openEditor(input, opts, sideBySide); } else { const resourceInput = input; @@ -284,9 +293,16 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick resourceInput.options = objects.assign(resourceInput.options || Object.create(null), modeOverrideOptions); } - this.editorService.openEditor(resourceInput, sideBySide).done(null, errors.onUnexpectedError); + openEditorPromise = this.editorService.openEditor(resourceInput, sideBySide); } + openEditorPromise.done( + () => this._historyService.block(false), + err => { + this._historyService.block(false); + errors.onUnexpectedError(err); + }); + return hideWidget; } } From e3fbbb99acf0ef6658477d4e643d0e83ed51466b Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Sat, 5 Nov 2016 08:37:58 +0100 Subject: [PATCH 11/12] fix compile error --- src/vs/workbench/browser/quickopen.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/browser/quickopen.ts b/src/vs/workbench/browser/quickopen.ts index e7e24ad6b49bb..739b21216e316 100644 --- a/src/vs/workbench/browser/quickopen.ts +++ b/src/vs/workbench/browser/quickopen.ts @@ -236,7 +236,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick constructor( private _editorService: IWorkbenchEditorService, private _historyService: IHistoryService, - private _configurationService: IConfigurationService + protected _configurationService: IConfigurationService ) { super(); } From dbf5a71468092978134b1a9e43741aaeb00bf7c6 Mon Sep 17 00:00:00 2001 From: Will Prater Date: Sat, 5 Nov 2016 11:11:07 -0700 Subject: [PATCH 12/12] remove unsued imports --- src/vs/workbench/browser/parts/quickopen/quickOpenController.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 541e9ce735618..c87f35fdd02a8 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -30,12 +30,10 @@ import { IResourceInput, IEditorInput } from 'vs/platform/editor/common/editor'; import { IModeService } from 'vs/editor/common/services/modeService'; import { getIconClasses } from 'vs/workbench/browser/labels'; import { IModelService } from 'vs/editor/common/services/modelService'; -// import { EditorInput, getUntitledOrFileResource, IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor'; import { EditorInput, getUntitledOrFileResource } from 'vs/workbench/common/editor'; import { WorkbenchComponent } from 'vs/workbench/common/component'; import Event, { Emitter } from 'vs/base/common/event'; import { IPartService } from 'vs/workbench/services/part/common/partService'; -// import { KeyMod } from 'vs/base/common/keyCodes'; import { QuickOpenHandler, QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions, EditorQuickOpenEntry } from 'vs/workbench/browser/quickopen'; import errors = require('vs/base/common/errors'); import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';