Skip to content

feat: add Collapse Other Results context menu action in search view#304994

Open
yogeshwaran-c wants to merge 2 commits into
microsoft:mainfrom
yogeshwaran-c:feat/collapse-other-search-results
Open

feat: add Collapse Other Results context menu action in search view#304994
yogeshwaran-c wants to merge 2 commits into
microsoft:mainfrom
yogeshwaran-c:feat/collapse-other-search-results

Conversation

@yogeshwaran-c
Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Feature

What is the current behavior?

In the search results view, users can collapse all results or expand recursively, but there is no way to collapse all results except the one they're focused on. Users who want to focus on a specific group of results have to manually collapse each other group.

Closes #163590

What is the new behavior?

Adds a "Collapse Other Results" context menu action that appears when right-clicking a file or folder match in the search results tree. Selecting it collapses all sibling results except the focused one, allowing users to quickly focus on a specific set of results.

Additional context

  • New command ID search.action.collapseOtherResults added to SearchCommandIds
  • Action registered with MenuId.SearchContext for folder and file focus contexts
  • Uses viewer.getNode() to get siblings and collapses all except the focused element

Adds a new context menu action in the search results view that collapses
all sibling results except the focused one. This allows users to focus
on a specific group of results without losing other results.

The action appears in the context menu when right-clicking a file or
folder match in the search results tree.

Closes microsoft#163590
@vs-code-engineering vs-code-engineering Bot added this to the 1.114.0 milestone Mar 26, 2026
@alexr00 alexr00 removed this from the 1.114.0 milestone Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a "Collapse Other Results" context menu action in the search results view, enabling users to collapse all sibling matches except the focused file/folder.

Changes:

  • New command ID CollapseOtherSearchResultsActionId added to SearchCommandIds.
  • New CollapseOtherResultsAction registered to MenuId.SearchContext for file/folder focus when search results exist.
  • Action obtains the focused element's parent node from the tree and collapses each non-focused, expanded sibling.
Show a summary per file
File Description
src/vs/workbench/contrib/search/common/constants.ts Adds the new CollapseOtherSearchResultsActionId command id.
src/vs/workbench/contrib/search/browser/searchActionsFind.ts Implements and registers the new CollapseOtherResultsAction context menu action.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Collapse other results" button in search view context menu

4 participants