Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scm.compactFolders. #221459

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading