提交 2be2eac6 编写于 作者: J Joao Moreno

Merge branch 'show_scm_providers' of https://github.com/shivammittal99/vscode...

Merge branch 'show_scm_providers' of https://github.com/shivammittal99/vscode into shivammittal99-show_scm_providers
......@@ -5,7 +5,6 @@
'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';
......@@ -20,11 +19,12 @@ 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 = localize('toggleGitViewlet', "Show Git");
static LABEL = nls.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,
localize('source control', "Source Control"),
nls.localize('source control', "Source Control"),
'scm',
36
);
......@@ -53,32 +53,38 @@ Registry.as(WorkbenchExtensions.Workbench)
// Register Action to Open Viewlet
Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions).registerWorkbenchAction(
new SyncActionDescriptor(OpenSCMViewletAction, VIEWLET_ID, localize('toggleSCMViewlet', "Show SCM"), {
new SyncActionDescriptor(OpenSCMViewletAction, VIEWLET_ID, nls.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',
localize('view', "View")
nls.localize('view', "View")
);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
id: 'scm',
order: 5,
title: nls.localize('scmConfigurationTitle', "SCM"),
type: 'object',
properties: {
'scm.showSingleSourceControlProvider': {
type: 'boolean',
description: nls.localize({ comment: ['This is the description for a setting'], key: 'showSingleSourceControlProvider' }, "Whether to show Source Control Provider for single repository."),
default: false
},
'scm.diffDecorations': {
type: 'string',
enum: ['all', 'gutter', 'overview', 'none'],
default: 'all',
description: localize('diffDecorations', "Controls diff decorations in the editor.")
description: nls.localize('diffDecorations', "Controls diff decorations in the editor.")
},
'scm.inputCounter': {
type: 'string',
enum: ['always', 'warn', 'off'],
default: 'warn',
description: localize('inputCounter', "Controls when to display the input counter.")
description: nls.localize('inputCounter', "Controls when to display the input counter.")
}
}
});
\ No newline at end of file
......@@ -56,7 +56,7 @@ import { format } from 'vs/base/common/strings';
import { ISpliceable, ISequence, ISplice } from 'vs/base/common/sequence';
import { firstIndex } from 'vs/base/common/arrays';
import { WorkbenchList, IListService } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
// TODO@Joao
// Need to subclass MenuItemActionItem in order to respect
......@@ -1035,12 +1035,14 @@ export class SCMViewlet extends PanelViewlet implements IViewModel {
@IWorkbenchEditorService protected editorService: IWorkbenchEditorService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IStorageService storageService: IStorageService,
@IExtensionService extensionService: IExtensionService
@IExtensionService extensionService: IExtensionService,
@IConfigurationService private configurationService: IConfigurationService
) {
super(VIEWLET_ID, { showHeaderInTitleWhenSingleView: true }, telemetryService, themeService);
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> {
......@@ -1057,6 +1059,12 @@ export class SCMViewlet extends PanelViewlet implements IViewModel {
this.onDidChangeRepositories();
}
private onConfigurationUpdated(e: IConfigurationChangeEvent): void {
if (e.affectsConfiguration('scm.showSingleSourceControlProvider')) {
this.onDidChangeRepositories();
}
}
private onDidAddRepository(repository: ISCMRepository): void {
const index = this._repositories.length;
this._repositories.push(repository);
......@@ -1087,7 +1095,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 > 1;
const shouldMainPanelBeVisible = this.scmService.repositories.length >
(this.configurationService.getValue('scm.showSingleSourceControlProvider') ? 0 : 1);
if (!!this.mainPanel === shouldMainPanelBeVisible) {
return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册