Skip to content

Commit 7a30d30

Browse files
authored
Introduce Collapse All Action to Loaded Scripts (microsoft#203560)
* Introduce Collapse All Action to Loaded Scripts Fixes: microsoft#64314 * Remove unneeded precondition * removed unneeded imports
1 parent 54ed9f5 commit 7a30d30

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
import * as nls from 'vs/nls';
77
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
88
import { normalize, isAbsolute, posix } from 'vs/base/common/path';
9-
import { ViewPane } from 'vs/workbench/browser/parts/views/viewPane';
9+
import { ViewPane, ViewAction } from 'vs/workbench/browser/parts/views/viewPane';
10+
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1011
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
1112
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
12-
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1313
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1414
import { renderViewTree } from 'vs/workbench/contrib/debug/browser/baseDebugView';
15-
import { IDebugSession, IDebugService, CONTEXT_LOADED_SCRIPTS_ITEM_TYPE } from 'vs/workbench/contrib/debug/common/debug';
15+
import { IDebugSession, IDebugService, CONTEXT_LOADED_SCRIPTS_ITEM_TYPE, LOADED_SCRIPTS_VIEW_ID } from 'vs/workbench/contrib/debug/common/debug';
1616
import { Source } from 'vs/workbench/contrib/debug/common/debugSource';
1717
import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
18-
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
18+
import { IContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1919
import { normalizeDriveLetter, tildify } from 'vs/base/common/labels';
2020
import { isWindows } from 'vs/base/common/platform';
2121
import { URI } from 'vs/base/common/uri';
@@ -34,6 +34,9 @@ import { DebugContentProvider } from 'vs/workbench/contrib/debug/common/debugCon
3434
import { ILabelService } from 'vs/platform/label/common/label';
3535
import type { ICompressedTreeNode } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
3636
import type { ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
37+
import { registerAction2, MenuId } from 'vs/platform/actions/common/actions';
38+
import { Codicon } from 'vs/base/common/codicons';
39+
3740
import { IViewDescriptorService } from 'vs/workbench/common/views';
3841
import { IOpenerService } from 'vs/platform/opener/common/opener';
3942
import { IThemeService } from 'vs/platform/theme/common/themeService';
@@ -622,6 +625,10 @@ export class LoadedScriptsView extends ViewPane {
622625
this.tree.layout(height, width);
623626
}
624627

628+
collapseAll(): void {
629+
this.tree.collapseAll();
630+
}
631+
625632
override dispose(): void {
626633
dispose(this.tree);
627634
dispose(this.treeLabels);
@@ -764,3 +771,24 @@ class LoadedScriptsFilter implements ITreeFilter<BaseTreeItem, FuzzyScore> {
764771
return TreeVisibility.Recurse;
765772
}
766773
}
774+
registerAction2(class Collapse extends ViewAction<LoadedScriptsView> {
775+
constructor() {
776+
super({
777+
id: 'loadedScripts.collapse',
778+
viewId: LOADED_SCRIPTS_VIEW_ID,
779+
title: nls.localize('collapse', "Collapse All"),
780+
f1: false,
781+
icon: Codicon.collapseAll,
782+
menu: {
783+
id: MenuId.ViewTitle,
784+
order: 30,
785+
group: 'navigation',
786+
when: ContextKeyExpr.equals('view', LOADED_SCRIPTS_VIEW_ID)
787+
}
788+
});
789+
}
790+
791+
runInView(_accessor: ServicesAccessor, view: LoadedScriptsView) {
792+
view.collapseAll();
793+
}
794+
});

0 commit comments

Comments
 (0)