From 7edbf1fd80e3ee2ae62bf907cac5fa80e423336b Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 14 Jun 2016 07:35:18 +0200 Subject: [PATCH] setting to control preview from quick open (#5554) --- .../parts/editor/editor.contribution.ts | 7 ++++- .../parts/quickopen/quickOpenController.ts | 10 +++++-- src/vs/workbench/common/editor.ts | 1 + .../parts/search/browser/openFileHandler.ts | 10 ++++--- .../parts/search/browser/openSymbolHandler.ts | 28 +++++++++++++------ 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/editor.contribution.ts b/src/vs/workbench/browser/parts/editor/editor.contribution.ts index a844439cb52..b53ab324e20 100644 --- a/src/vs/workbench/browser/parts/editor/editor.contribution.ts +++ b/src/vs/workbench/browser/parts/editor/editor.contribution.ts @@ -411,7 +411,12 @@ configurationRegistry.registerConfiguration({ }, 'workbench.previewEditors': { 'type': 'boolean', - 'description': nls.localize('previewEditors', "Controls if opened editors show as preview until getting pinned."), + 'description': nls.localize('previewEditors', "Controls if opened editors show as preview until getting pinned. Set to false to always open editors pinned."), + 'default': true + }, + 'workbench.quickOpenPreviews': { + 'type': 'boolean', + 'description': nls.localize('quickOpenPreviews', "Controls if editors opened from quick open show as preview. Set to false to always open editors from quick open pinned."), 'default': true } } diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 0ff11a2332d..fafbc01b194 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -22,7 +22,7 @@ import {ITree, IElementCallback} from 'vs/base/parts/tree/browser/tree'; import labels = require('vs/base/common/labels'); import paths = require('vs/base/common/paths'); import {Registry} from 'vs/platform/platform'; -import {EditorInput, getUntitledOrFileResource} from 'vs/workbench/common/editor'; +import {EditorInput, EditorOptions, getUntitledOrFileResource, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; import {WorkbenchComponent} from 'vs/workbench/common/component'; import Event, {Emitter} from 'vs/base/common/event'; import {Identifiers} from 'vs/workbench/common/constants'; @@ -33,6 +33,7 @@ import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/edito import {IPickOpenEntry, IInputOptions, IQuickOpenService, IPickOptions, IShowOptions} from 'vs/workbench/services/quickopen/common/quickOpenService'; import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService'; import {IStorageService} from 'vs/platform/storage/common/storage'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IEventService} from 'vs/platform/event/common/event'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {IMessageService, Severity} from 'vs/platform/message/common/message'; @@ -982,6 +983,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { input: EditorInput, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IInstantiationService private instantiationService: IInstantiationService, + @IConfigurationService private configurationService: IConfigurationService, @IWorkspaceContextService private contextService: IWorkspaceContextService ) { super(editorService); @@ -1020,8 +1022,10 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry { public run(mode: Mode, context: IEntryRunContext): boolean { if (mode === Mode.OPEN) { - let sideBySide = !context.quickNavigateConfiguration && context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; - this.editorService.openEditor(this.input, null, sideBySide).done(null, errors.onUnexpectedError); + const sideBySide = !context.quickNavigateConfiguration && context.keymods.indexOf(KeyMod.CtrlCmd) >= 0; + const pinned = !this.configurationService.getConfiguration().workbench.quickOpenPreviews; + + this.editorService.openEditor(this.input, EditorOptions.create({ pinned }), sideBySide).done(null, errors.onUnexpectedError); return true; } diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 03bdb8adfe7..afba732b665 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -667,5 +667,6 @@ export interface IWorkbenchEditorConfiguration { workbench: { showEditorTabs: boolean; previewEditors: boolean; + quickOpenPreviews: boolean; }; } \ 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 bb8fbb07a62..a69313c48c8 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -15,7 +15,7 @@ import {QuickOpenEntry, QuickOpenModel} from 'vs/base/parts/quickopen/browser/qu import {QuickOpenHandler, EditorQuickOpenEntry} from 'vs/workbench/browser/quickopen'; import {QueryBuilder} from 'vs/workbench/parts/search/common/searchQuery'; import {ITextFileService} from 'vs/workbench/parts/files/common/files'; -import {EditorInput, getOutOfWorkspaceEditorResources} from 'vs/workbench/common/editor'; +import {EditorInput, getOutOfWorkspaceEditorResources, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; import {IResourceInput} from 'vs/platform/editor/common/editor'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; @@ -37,6 +37,7 @@ export class FileEntry extends EditorQuickOpenEntry { resource: URI, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IInstantiationService private instantiationService: IInstantiationService, + @IConfigurationService private configurationService: IConfigurationService, @IWorkspaceContextService contextService: IWorkspaceContextService ) { super(editorService); @@ -73,12 +74,13 @@ export class FileEntry extends EditorQuickOpenEntry { public getInput(): IResourceInput | EditorInput { let input: IResourceInput = { resource: this.resource, + options: { + pinned: !this.configurationService.getConfiguration().workbench.quickOpenPreviews + } }; if (this.range) { - input.options = { - selection: this.range - }; + input.options.selection = this.range; } return input; diff --git a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts index 89588f8eea5..dc65da6d529 100644 --- a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts +++ b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts @@ -13,13 +13,14 @@ import {QuickOpenModel, QuickOpenEntry, IHighlight} from 'vs/base/parts/quickope import {IAutoFocus} from 'vs/base/parts/quickopen/common/quickOpen'; import filters = require('vs/base/common/filters'); import {IRange} from 'vs/editor/common/editorCommon'; -import {EditorInput} from 'vs/workbench/common/editor'; +import {EditorInput, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; 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 {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace'; import {IModeService} from 'vs/editor/common/services/modeService'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {ITypeBearing, getNavigateToItems} from 'vs/workbench/parts/search/common/search'; class SymbolEntry extends EditorQuickOpenEntry { @@ -30,7 +31,17 @@ class SymbolEntry extends EditorQuickOpenEntry { private type: string; private range: IRange; - constructor(name: string, parameters: string, description: string, resource: URI, type: string, range: IRange, highlights: IHighlight[], editorService: IWorkbenchEditorService) { + constructor( + name: string, + parameters: string, + description: string, + resource: URI, + type: string, + range: IRange, + highlights: IHighlight[], + @IWorkbenchEditorService editorService: IWorkbenchEditorService, + @IConfigurationService private configurationService: IConfigurationService + ) { super(editorService); this.name = name; @@ -73,14 +84,15 @@ class SymbolEntry extends EditorQuickOpenEntry { public getInput(): IResourceInput | EditorInput { let input: IResourceInput = { resource: this.resource, + options: { + pinned: !this.configurationService.getConfiguration().workbench.quickOpenPreviews + } }; if (this.range) { - input.options = { - selection: { - startLineNumber: this.range.startLineNumber, - startColumn: this.range.startColumn - } + input.options.selection = { + startLineNumber: this.range.startLineNumber, + startColumn: this.range.startColumn }; } @@ -179,7 +191,7 @@ export class OpenSymbolHandler extends QuickOpenHandler { container = element.containerName || path; } - results.push(new SymbolEntry(element.name, element.parameters, container, resource, element.type, element.range, highlights, this.editorService)); + results.push(this.instantiationService.createInstance(SymbolEntry, element.name, element.parameters, container, resource, element.type, element.range, highlights)); } } }); -- GitLab