Skip to content

Commit 11a6cf4

Browse files
authored
SCM - refactor incoming/outgoing settings (#198368)
1 parent 9a207df commit 11a6cf4

File tree

2 files changed

+46
-30
lines changed

2 files changed

+46
-30
lines changed

src/vs/workbench/contrib/scm/browser/scm.contribution.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -298,29 +298,32 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
298298
markdownDescription: localize('showActionButton', "Controls whether an action button can be shown in the Source Control view."),
299299
default: true
300300
},
301+
'scm.showIncomingChanges': {
302+
type: 'string',
303+
enum: ['always', 'never', 'auto'],
304+
enumDescriptions: [
305+
localize('scm.showIncomingChanges.always', "Always show incoming changes in the Source Control view."),
306+
localize('scm.showIncomingChanges.never', "Never show incoming changes in the Source Control view."),
307+
localize('scm.showIncomingChanges.auto', "Only show incoming changes in the Source Control view when any exist."),
308+
],
309+
description: localize('scm.showIncomingChanges', "Controls whether incoming changes are shown in the Source Control view."),
310+
default: 'never'
311+
},
312+
'scm.showOutgoingChanges': {
313+
type: 'string',
314+
enum: ['always', 'never', 'auto'],
315+
enumDescriptions: [
316+
localize('scm.showOutgoingChanges.always', "Always show outgoing changes in the Source Control view."),
317+
localize('scm.showOutgoingChanges.never', "Never show outgoing changes in the Source Control view."),
318+
localize('scm.showOutgoingChanges.auto', "Only show outgoing changes in the Source Control view when any exist."),
319+
],
320+
description: localize('scm.showOutgoingChanges', "Controls whether outgoing changes are shown in the Source Control view."),
321+
default: 'never'
322+
},
301323
'scm.experimental.showSyncView': {
302324
type: 'boolean',
303325
description: localize('showSyncView', "Controls whether the Source Control Sync view is shown."),
304326
default: false
305-
},
306-
'scm.experimental.showSyncInformation': {
307-
type: 'object',
308-
description: localize('showSyncInformation', "Controls whether incoming/outgoing changes are shown in the Source Control view."),
309-
additionalProperties: false,
310-
properties: {
311-
'incoming': {
312-
type: 'boolean',
313-
description: localize('showSyncInformationIncoming', "Show incoming changes in the Source Control view."),
314-
},
315-
'outgoing': {
316-
type: 'boolean',
317-
description: localize('showSyncInformationOutgoing', "Show outgoing changes in the Source Control view."),
318-
},
319-
},
320-
default: {
321-
'incoming': false,
322-
'outgoing': false
323-
}
324327
}
325328
}
326329
});

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ type TreeElement =
117117
IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement> |
118118
SCMViewSeparatorElement;
119119

120+
type ShowChangesSetting = 'always' | 'never' | 'auto';
121+
120122
registerColor('scm.historyItemAdditionsForeground', {
121123
dark: 'gitDecoration.addedResourceForeground',
122124
light: 'gitDecoration.addedResourceForeground',
@@ -1023,8 +1025,6 @@ class SCMTreeFilter implements ITreeFilter<TreeElement> {
10231025
return true;
10241026
} else if (isSCMResourceGroup(element)) {
10251027
return element.resources.length > 0 || !element.hideWhenEmpty;
1026-
} else if (isSCMHistoryItemGroupTreeElement(element)) {
1027-
return (element.count ?? 0) > 0;
10281028
} else if (isSCMViewSeparator(element)) {
10291029
return element.repository.provider.groups.some(g => g.resources.length > 0);
10301030
} else {
@@ -2351,8 +2351,11 @@ export class SCMViewPane extends ViewPane {
23512351
private _alwaysShowRepositories = false;
23522352
get alwaysShowRepositories(): boolean { return this._alwaysShowRepositories; }
23532353

2354-
private _showSyncInformation: { incoming: boolean; outgoing: boolean } = { incoming: false, outgoing: false };
2355-
get showSyncInformation(): { incoming: boolean; outgoing: boolean } { return this._showSyncInformation; }
2354+
private _showIncomingChanges: ShowChangesSetting | undefined;
2355+
get showIncomingChanges(): ShowChangesSetting { return this._showIncomingChanges ?? 'never'; }
2356+
2357+
private _showOutgoingChanges: ShowChangesSetting | undefined;
2358+
get showOutgoingChanges(): ShowChangesSetting { return this._showOutgoingChanges ?? 'never'; }
23562359

23572360
private readonly items = new DisposableMap<ISCMRepository, IDisposable>();
23582361
private readonly visibilityDisposables = new DisposableStore();
@@ -2468,10 +2471,15 @@ export class SCMViewPane extends ViewPane {
24682471
await this.tree.setInput(this.scmViewService, viewState);
24692472

24702473
const onDidChangeConfiguration = (e?: IConfigurationChangeEvent) => {
2471-
if (!e || e.affectsConfiguration('scm.showActionButton') || e.affectsConfiguration('scm.alwaysShowRepositories') || e.affectsConfiguration('scm.experimental.showSyncInformation')) {
2474+
if (!e ||
2475+
e.affectsConfiguration('scm.showActionButton') ||
2476+
e.affectsConfiguration('scm.alwaysShowRepositories') ||
2477+
e.affectsConfiguration('scm.showIncomingChanges') ||
2478+
e.affectsConfiguration('scm.showOutgoingChanges')) {
24722479
this._showActionButton = this.configurationService.getValue<boolean>('scm.showActionButton');
24732480
this._alwaysShowRepositories = this.configurationService.getValue<boolean>('scm.alwaysShowRepositories');
2474-
this._showSyncInformation = this.configurationService.getValue<{ incoming: boolean; outgoing: boolean }>('scm.experimental.showSyncInformation');
2481+
this._showIncomingChanges = this.configurationService.getValue<ShowChangesSetting>('scm.showIncomingChanges');
2482+
this._showOutgoingChanges = this.configurationService.getValue<ShowChangesSetting>('scm.showOutgoingChanges');
24752483

24762484
if (e?.affectsConfiguration('scm.alwaysShowRepositories')) {
24772485
this.updateActions();
@@ -2521,7 +2529,7 @@ export class SCMViewPane extends ViewPane {
25212529
actionRunner.onWillRun(() => this.tree.domFocus(), this, this.disposables);
25222530
this.disposables.add(actionRunner);
25232531

2524-
this.treeDataSource = this.instantiationService.createInstance(SCMTreeDataSource, () => this.viewMode, () => this.alwaysShowRepositories, () => this.showActionButton, () => this.showSyncInformation);
2532+
this.treeDataSource = this.instantiationService.createInstance(SCMTreeDataSource, () => this.viewMode, () => this.alwaysShowRepositories, () => this.showActionButton, () => this.showIncomingChanges, () => this.showOutgoingChanges);
25252533

25262534
this.tree = this.instantiationService.createInstance(
25272535
WorkbenchCompressibleAsyncDataTree,
@@ -2970,7 +2978,8 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
29702978
private readonly viewMode: () => ViewMode,
29712979
private readonly alwaysShowRepositories: () => boolean,
29722980
private readonly showActionButton: () => boolean,
2973-
private readonly showSyncInformation: () => { incoming: boolean; outgoing: boolean },
2981+
private readonly showIncomingChanges: () => ShowChangesSetting,
2982+
private readonly showOutgoingChanges: () => ShowChangesSetting,
29742983
@ISCMViewService private readonly scmViewService: ISCMViewService,
29752984
@IUriIdentityService private uriIdentityService: IUriIdentityService,
29762985
) { }
@@ -3088,7 +3097,7 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
30883097
const historyProvider = scmProvider.historyProvider;
30893098
const currentHistoryItemGroup = historyProvider?.currentHistoryItemGroup;
30903099

3091-
if (!historyProvider || !currentHistoryItemGroup || (this.showSyncInformation().incoming === false && this.showSyncInformation().outgoing === false)) {
3100+
if (!historyProvider || !currentHistoryItemGroup || (this.showIncomingChanges() === 'never' && this.showOutgoingChanges() === 'never')) {
30923101
return [];
30933102
}
30943103

@@ -3105,7 +3114,9 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
31053114
}
31063115

31073116
// Incoming
3108-
if (this.showSyncInformation().incoming && historyItemGroupDetails?.incoming) {
3117+
if (historyItemGroupDetails?.incoming &&
3118+
(this.showIncomingChanges() === 'always' ||
3119+
(this.showIncomingChanges() === 'auto' && (historyItemGroupDetails.incoming.count ?? 0) > 0))) {
31093120
children.push({
31103121
...historyItemGroupDetails.incoming,
31113122
repository: element,
@@ -3114,7 +3125,9 @@ class SCMTreeDataSource implements IAsyncDataSource<ISCMViewService, TreeElement
31143125
}
31153126

31163127
// Outgoing
3117-
if (this.showSyncInformation().outgoing && historyItemGroupDetails?.outgoing) {
3128+
if (historyItemGroupDetails?.outgoing &&
3129+
(this.showOutgoingChanges() === 'always' ||
3130+
(this.showOutgoingChanges() === 'auto' && (historyItemGroupDetails.outgoing.count ?? 0) > 0))) {
31183131
children.push({
31193132
...historyItemGroupDetails.outgoing,
31203133
repository: element,

0 commit comments

Comments
 (0)