From 5e4f10511768a2757714c9d13cd13325b5d5a87f Mon Sep 17 00:00:00 2001 From: Shivam Mittal Date: Tue, 28 Nov 2017 16:34:13 +0530 Subject: [PATCH 1/5] Setting to always show Source Control Providers Show source control provider even for single repository Closes #38785 Signed-off-by: Shivam Mittal --- .../scm/electron-browser/scm.contribution.ts | 27 +++++++++++++++---- .../parts/scm/electron-browser/scmViewlet.ts | 14 ++++++++-- 2 files changed, 34 insertions(+), 7 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 2dc55faba6d..50cfa92f40d 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scm.contribution.ts @@ -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'; @@ -19,11 +18,13 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi 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 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); @@ -36,7 +37,7 @@ Registry.as(WorkbenchExtensions.Workbench) const viewletDescriptor = new ViewletDescriptor( SCMViewlet, VIEWLET_ID, - localize('source control', "Source Control"), + nls.localize('source control', "Source Control"), 'scm', 36 ); @@ -52,12 +53,28 @@ Registry.as(WorkbenchExtensions.Workbench) // Register Action to Open Viewlet Registry.as(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") ); + +// Register configuration +const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); +configurationRegistry.registerConfiguration({ + id: 'scm', + order: 20, + 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 + } + } +}); \ 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 4530cff6727..6f40a561516 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts @@ -56,6 +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, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; // TODO@Joao // Need to subclass MenuItemActionItem in order to respect @@ -980,12 +981,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 { @@ -1002,6 +1005,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); @@ -1032,7 +1041,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; From 641e287bf6a8e6b023ba9449d76853a633e03628 Mon Sep 17 00:00:00 2001 From: Fong Kye Pascal Date: Fri, 8 Dec 2017 21:05:43 +0100 Subject: [PATCH 2/5] fix: #39738 Replaces starting tilde with home directory when entered in git clone prompt --- extensions/git/src/commands.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 07e7594aa6b..b6c1c8bd33d 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -307,6 +307,10 @@ export class CommandCenter { return ''; } + private handlePathTilde(path: string): string { + return path.replace(/^~/, os.homedir()); + } + private static cloneId = 0; @command('git.clone') @@ -330,11 +334,10 @@ export class CommandCenter { const config = workspace.getConfiguration('git'); let value = config.get('defaultCloneDirectory') || os.homedir(); - value = value.replace(/^~/, os.homedir()); const parentPath = await window.showInputBox({ prompt: localize('parent', "Parent Directory"), - value, + value: this.handlePathTilde(value), ignoreFocusOut: true }); @@ -358,7 +361,7 @@ export class CommandCenter { statusBarItem.command = cancelCommandId; statusBarItem.show(); - const clonePromise = this.git.clone(url, parentPath, tokenSource.token); + const clonePromise = this.git.clone(url, this.handlePathTilde(parentPath), tokenSource.token); try { window.withProgress({ location: ProgressLocation.SourceControl, title: localize('cloning', "Cloning git repository...") }, () => clonePromise); From 938dc015d2dca640663c3f6115e8e7f51f88b4e5 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Dec 2017 16:12:15 +0100 Subject: [PATCH 3/5] :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; From eb43c80ecc3c2a3f6d4ad1de3e6b6abea7a4b919 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Dec 2017 16:17:39 +0100 Subject: [PATCH 4/5] :lipstick: --- extensions/git/src/commands.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 4653e3ef902..9b20e9487bb 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -328,10 +328,6 @@ export class CommandCenter { return ''; } - private handlePathTilde(path: string): string { - return path.replace(/^~/, os.homedir()); - } - private static cloneId = 0; @command('git.clone') @@ -358,7 +354,7 @@ export class CommandCenter { const parentPath = await window.showInputBox({ prompt: localize('parent', "Parent Directory"), - value: this.handlePathTilde(value), + value, ignoreFocusOut: true }); @@ -382,7 +378,7 @@ export class CommandCenter { statusBarItem.command = cancelCommandId; statusBarItem.show(); - const clonePromise = this.git.clone(url, this.handlePathTilde(parentPath), tokenSource.token); + const clonePromise = this.git.clone(url, parentPath.replace(/^~/, os.homedir()), tokenSource.token); try { window.withProgress({ location: ProgressLocation.SourceControl, title: localize('cloning', "Cloning git repository...") }, () => clonePromise); @@ -1329,7 +1325,7 @@ export class CommandCenter { const remoteRefs = repository.refs; const remoteRefsFiltered = remoteRefs.filter(r => (r.remote === remotePick.label)); - const branchPicks = remoteRefsFiltered.map(r => ({ label: r.name})) as {label : string; description : string}[]; + const branchPicks = remoteRefsFiltered.map(r => ({ label: r.name })) as { label: string; description: string }[]; const branchPick = await window.showQuickPick(branchPicks, { placeHolder }); if (!branchPick) { @@ -1338,7 +1334,7 @@ export class CommandCenter { const remoteCharCnt = remotePick.label.length; - repository.pull(false, remotePick.label, branchPick.label.slice(remoteCharCnt+1)); + repository.pull(false, remotePick.label, branchPick.label.slice(remoteCharCnt + 1)); } @command('git.pull', { repository: true }) From 195c346f06168ac786c7a5f40346152cc7121a4f Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Dec 2017 16:18:05 +0100 Subject: [PATCH 5/5] :lipstick: --- src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts index 5270b96f29b..84b6588527b 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts @@ -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, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; // TODO@Joao // Need to subclass MenuItemActionItem in order to respect