From ad55bcd31bf999ea573a89276749677bea63debd Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 14 Jun 2016 12:21:04 +0200 Subject: [PATCH] Never show pinEditor action when "workbench.previewEditors": false (fixes #7650) --- .../browser/parts/editor/tabsTitleControl.ts | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts index edf604067c2..9f73c4b6e99 100644 --- a/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts +++ b/src/vs/workbench/browser/parts/editor/tabsTitleControl.ts @@ -18,12 +18,13 @@ import {isMacintosh} from 'vs/base/common/platform'; import {Builder, $} from 'vs/base/browser/builder'; import {MIME_BINARY} from 'vs/base/common/mime'; import {Position} from 'vs/platform/editor/common/editor'; -import {IEditorGroup, IEditorIdentifier, asFileEditorInput, EditorOptions} from 'vs/workbench/common/editor'; +import {IEditorGroup, IEditorIdentifier, asFileEditorInput, EditorOptions, IWorkbenchEditorConfiguration} from 'vs/workbench/common/editor'; import {ToolBar} from 'vs/base/browser/ui/toolbar/toolbar'; import {StandardKeyboardEvent} from 'vs/base/browser/keyboardEvent'; import {CommonKeybindings as Kb} from 'vs/base/common/keyCodes'; import {ActionBar, Separator} from 'vs/base/browser/ui/actionbar/actionbar'; import {StandardMouseEvent} from 'vs/base/browser/mouseEvent'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IContextMenuService} from 'vs/platform/contextview/browser/contextView'; import {IEditorGroupService} from 'vs/workbench/services/group/common/groupService'; @@ -51,9 +52,12 @@ export class TabsTitleControl extends TitleControl { private currentPrimaryGroupActionIds: string[]; private currentSecondaryGroupActionIds: string[]; + private previewEditors: boolean; + constructor( @IContextMenuService contextMenuService: IContextMenuService, @IInstantiationService instantiationService: IInstantiationService, + @IConfigurationService private configurationService: IConfigurationService, @IWorkbenchEditorService editorService: IWorkbenchEditorService, @IEditorGroupService editorGroupService: IEditorGroupService, @IKeybindingService keybindingService: IKeybindingService, @@ -66,6 +70,18 @@ export class TabsTitleControl extends TitleControl { this.currentSecondaryGroupActionIds = []; this.tabDisposeables = []; + + this.onConfigurationUpdated(configurationService.getConfiguration()); + + this.registerListeners(); + } + + private registerListeners(): void { + this.toDispose.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated(e.config))); + } + + private onConfigurationUpdated(config: IWorkbenchEditorConfiguration): void { + this.previewEditors = config.workbench.previewEditors; } public setContext(group: IEditorGroup): void { @@ -548,11 +564,13 @@ export class TabsTitleControl extends TitleControl { const actions: IAction[] = [ this.closeEditorAction, this.closeOtherEditorsAction, - this.closeRightEditorsAction, - new Separator(), - this.pinEditorAction, + this.closeRightEditorsAction ]; + if (this.previewEditors) { + actions.push(new Separator(), this.pinEditorAction); + } + // Actions: For active editor if (group.isActive(editor)) { const editorActions = this.getEditorActions(group);