Skip to content

Commit 95885d7

Browse files
authored
feat. add a menu item 'expand-select' to expand subtree in search view (microsoft#206033)
* feat. add a menu item 'Expand All' to expand subtree * feat. update menu text
1 parent 9ccaf9d commit 95885d7

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/vs/workbench/contrib/search/browser/searchActionsFind.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ registerAction2(class RestrictSearchToFolderAction extends Action2 {
7777
}
7878
});
7979

80+
81+
registerAction2(class ExpandSelectedTreeCommandAction extends Action2 {
82+
constructor(
83+
) {
84+
super({
85+
id: Constants.SearchCommandIds.ExpandRecursivelyCommandId,
86+
title: nls.localize('search.expandRecursively', "Expand Recursively"),
87+
category,
88+
menu: [{
89+
id: MenuId.SearchContext,
90+
when: ContextKeyExpr.and(
91+
ContextKeyExpr.or(Constants.SearchContext.FileFocusKey, Constants.SearchContext.FolderFocusKey),
92+
Constants.SearchContext.HasSearchResults
93+
),
94+
group: 'search',
95+
order: 4
96+
}]
97+
});
98+
}
99+
100+
override async run(accessor: any): Promise<any> {
101+
await expandSelectSubtree(accessor);
102+
}
103+
});
104+
80105
registerAction2(class ExcludeFolderFromSearchAction extends Action2 {
81106
constructor() {
82107
super({
@@ -270,6 +295,16 @@ registerAction2(class FindInWorkspaceAction extends Action2 {
270295
});
271296

272297
//#region Helpers
298+
function expandSelectSubtree(accessor: ServicesAccessor) {
299+
const viewsService = accessor.get(IViewsService);
300+
const searchView = getSearchView(viewsService);
301+
if (searchView) {
302+
const viewer = searchView.getControl();
303+
const selected = viewer.getFocus()[0];
304+
viewer.expand(selected, true);
305+
}
306+
}
307+
273308
async function searchWithFolderCommand(accessor: ServicesAccessor, isFromExplorer: boolean, isIncludes: boolean, resource?: URI, folderMatch?: FolderMatchWithResource) {
274309
const listService = accessor.get(IListService);
275310
const fileService = accessor.get(IFileService);

src/vs/workbench/contrib/search/common/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const enum SearchCommandIds {
3838
ToggleSearchOnTypeActionId = 'workbench.action.toggleSearchOnType',
3939
CollapseSearchResultsActionId = 'search.action.collapseSearchResults',
4040
ExpandSearchResultsActionId = 'search.action.expandSearchResults',
41+
ExpandRecursivelyCommandId = 'search.action.expandRecursively',
4142
ClearSearchResultsActionId = 'search.action.clearSearchResults',
4243
ViewAsTreeActionId = 'search.action.viewAsTree',
4344
ViewAsListActionId = 'search.action.viewAsList',

0 commit comments

Comments
 (0)