提交 938dc015 编写于 作者: J Joao Moreno

💄

上级 2be2eac6
......@@ -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<IWorkbenchContributionsRegistry>(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<IWorkbenchActionRegistry>(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<IConfigurationRegistry>(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
......@@ -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<void> {
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册