From 938dc015d2dca640663c3f6115e8e7f51f88b4e5 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Dec 2017 16:12:15 +0100 Subject: [PATCH] :lipstick: --- .../scm/electron-browser/scm.contribution.ts | 20 +++++++++---------- .../parts/scm/electron-browser/scmViewlet.ts | 17 +++++++--------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts b/src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts index b838a3ad4f3..c8079172f45 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts @@ -5,6 +5,7 @@ 'use strict'; +import { localize } from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { DirtyDiffWorkbenchController } from './dirtydiffDecorator'; @@ -19,12 +20,11 @@ import { StatusUpdater, StatusBarController } from './scmActivity'; import { SCMViewlet } from 'vs/workbench/parts/scm/electron-browser/scmViewlet'; import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry'; -import * as nls from 'vs/nls'; class OpenSCMViewletAction extends ToggleViewletAction { static readonly ID = VIEWLET_ID; - static LABEL = nls.localize('toggleGitViewlet', "Show Git"); + static LABEL = localize('toggleGitViewlet', "Show Git"); constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @IWorkbenchEditorService editorService: IWorkbenchEditorService) { super(id, label, VIEWLET_ID, viewletService, editorService); @@ -37,7 +37,7 @@ Registry.as(WorkbenchExtensions.Workbench) const viewletDescriptor = new ViewletDescriptor( SCMViewlet, VIEWLET_ID, - nls.localize('source control', "Source Control"), + localize('source control', "Source Control"), 'scm', 36 ); @@ -53,38 +53,38 @@ Registry.as(WorkbenchExtensions.Workbench) // Register Action to Open Viewlet Registry.as(WorkbenchActionExtensions.WorkbenchActions).registerWorkbenchAction( - new SyncActionDescriptor(OpenSCMViewletAction, VIEWLET_ID, nls.localize('toggleSCMViewlet', "Show SCM"), { + new SyncActionDescriptor(OpenSCMViewletAction, VIEWLET_ID, localize('toggleSCMViewlet', "Show SCM"), { primary: null, win: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G }, linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G }, mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_G } }), 'View: Show SCM', - nls.localize('view', "View") + localize('view', "View") ); Registry.as(ConfigurationExtensions.Configuration).registerConfiguration({ id: 'scm', order: 5, - title: nls.localize('scmConfigurationTitle', "SCM"), + title: localize('scmConfigurationTitle', "SCM"), type: 'object', properties: { - 'scm.showSingleSourceControlProvider': { + 'scm.alwaysShowProviders': { type: 'boolean', - description: nls.localize({ comment: ['This is the description for a setting'], key: 'showSingleSourceControlProvider' }, "Whether to show Source Control Provider for single repository."), + description: localize('alwaysShowProviders', "Whether to always show the Source Control Provider section."), default: false }, 'scm.diffDecorations': { type: 'string', enum: ['all', 'gutter', 'overview', 'none'], default: 'all', - description: nls.localize('diffDecorations', "Controls diff decorations in the editor.") + description: localize('diffDecorations', "Controls diff decorations in the editor.") }, 'scm.inputCounter': { type: 'string', enum: ['always', 'warn', 'off'], default: 'warn', - description: nls.localize('inputCounter', "Controls when to display the input counter.") + description: localize('inputCounter', "Controls when to display the input counter.") } } }); \ No newline at end of file diff --git a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts index adcbaa3d0a7..5270b96f29b 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts @@ -8,7 +8,7 @@ import 'vs/css!./media/scmViewlet'; import { localize } from 'vs/nls'; import { TPromise } from 'vs/base/common/winjs.base'; -import Event, { Emitter, chain, mapEvent, anyEvent } from 'vs/base/common/event'; +import Event, { Emitter, chain, mapEvent, anyEvent, filterEvent } from 'vs/base/common/event'; import { domEvent, stop } from 'vs/base/browser/event'; import { basename } from 'vs/base/common/paths'; import { onUnexpectedError } from 'vs/base/common/errors'; @@ -1042,7 +1042,6 @@ export class SCMViewlet extends PanelViewlet implements IViewModel { this.menus = instantiationService.createInstance(SCMMenus, undefined); this.menus.onDidChangeTitle(this.updateTitleArea, this, this.disposables); - this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e))); } async create(parent: Builder): TPromise { @@ -1056,13 +1055,11 @@ export class SCMViewlet extends PanelViewlet implements IViewModel { this.scmService.onDidAddRepository(this.onDidAddRepository, this, this.disposables); this.scmService.onDidRemoveRepository(this.onDidRemoveRepository, this, this.disposables); this.scmService.repositories.forEach(r => this.onDidAddRepository(r)); - this.onDidChangeRepositories(); - } - private onConfigurationUpdated(e: IConfigurationChangeEvent): void { - if (e.affectsConfiguration('scm.showSingleSourceControlProvider')) { - this.onDidChangeRepositories(); - } + const onDidUpdateConfiguration = filterEvent(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('scm.alwaysShowProviders')); + onDidUpdateConfiguration(this.onDidChangeRepositories, this, this.disposables); + + this.onDidChangeRepositories(); } private onDidAddRepository(repository: ISCMRepository): void { @@ -1095,8 +1092,8 @@ export class SCMViewlet extends PanelViewlet implements IViewModel { private onDidChangeRepositories(): void { toggleClass(this.el, 'empty', this.scmService.repositories.length === 0); - const shouldMainPanelBeVisible = this.scmService.repositories.length > - (this.configurationService.getValue('scm.showSingleSourceControlProvider') ? 0 : 1); + const shouldMainPanelAlwaysBeVisible = this.configurationService.getValue('scm.alwaysShowProviders'); + const shouldMainPanelBeVisible = shouldMainPanelAlwaysBeVisible || this.scmService.repositories.length > 1; if (!!this.mainPanel === shouldMainPanelBeVisible) { return; -- GitLab