Skip to content

Commit

Permalink
handle history blocking in EditorQuickOpenEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
wprater committed Oct 25, 2016
1 parent 09bebf0 commit 98cf219
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/vs/workbench/browser/quickopen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<IWorkbenchEditorConfiguration>().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<IEditor>;
let input = this.getInput();
if (input instanceof EditorInput) {
let opts = this.getOptions();
Expand All @@ -276,17 +285,24 @@ 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 = <IResourceInput>input;

if (modeOverrideOptions) {
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;
}
}
Expand Down

0 comments on commit 98cf219

Please sign in to comment.