Skip to content

Commit

Permalink
Add scm.compactFolders. (#221459)
Browse files Browse the repository at this point in the history
* Add scm.compactFolders.

* compactFolders default true

* Update setting description and use observableConfigValue

---------

Co-authored-by: Ladislau Szomoru <[email protected]>
  • Loading branch information
tisilent and lszomoru authored Jul 29, 2024
1 parent cff5b57 commit cfe1666
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/scm/browser/scm.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
type: 'boolean',
description: localize('scm.showHistoryGraph', "Controls whether to render incoming/outgoing changes using a graph in the Source Control view."),
default: true
},
'scm.compactFolders': {
type: 'boolean',
description: localize('scm.compactFolders', "Controls whether the Source Control view should render folders in a compact form. In such a form, single child folders will be compressed in a combined tree element."),
default: true
}
}
});
Expand Down
10 changes: 10 additions & 0 deletions src/vs/workbench/contrib/scm/browser/scmViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { IWorkbenchLayoutService, Position } from 'vs/workbench/services/layout/browser/layoutService';
import { fromNow } from 'vs/base/common/date';
import { equals } from 'vs/base/common/arrays';
import { observableConfigValue } from 'vs/platform/observable/common/platformObservableUtils';

// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;
Expand Down Expand Up @@ -3271,6 +3272,8 @@ export class SCMViewPane extends ViewPane {
const treeDataSource = this.instantiationService.createInstance(SCMTreeDataSource, () => this.viewMode, this.historyProviderDataSource);
this.disposables.add(treeDataSource);

const compressionEnabled = observableConfigValue('scm.compactFolders', true, this.configurationService);

this.tree = this.instantiationService.createInstance(
WorkbenchCompressibleAsyncDataTree,
'SCM Tree Repo',
Expand Down Expand Up @@ -3300,6 +3303,7 @@ export class SCMViewPane extends ViewPane {
sorter: new SCMTreeSorter(() => this.viewMode, () => this.viewSortKey),
keyboardNavigationLabelProvider: this.instantiationService.createInstance(SCMTreeKeyboardNavigationLabelProvider, () => this.viewMode),
overrideStyles: this.getLocationBasedColors().listOverrideStyles,
compressionEnabled: compressionEnabled.get(),
collapseByDefault: (e: unknown) => {
// Repository, Resource Group, Resource Folder (Tree), History Item Change Folder (Tree)
if (isSCMRepository(e) || isSCMResourceGroup(e) || isSCMResourceNode(e) || isSCMHistoryItemChangeNode(e)) {
Expand All @@ -3319,6 +3323,12 @@ export class SCMViewPane extends ViewPane {
this.tree.onDidScroll(this.inputRenderer.clearValidation, this.inputRenderer, this.disposables);
Event.filter(this.tree.onDidChangeCollapseState, e => isSCMRepository(e.node.element?.element), this.disposables)(this.updateRepositoryCollapseAllContextKeys, this, this.disposables);

this.disposables.add(autorun(reader => {
this.tree.updateOptions({
compressionEnabled: compressionEnabled.read(reader)
});
}));

append(container, overflowWidgetsDomNode);
}

Expand Down

0 comments on commit cfe1666

Please sign in to comment.