Skip to content

Conversation

@eidriahn
Copy link
Contributor

Fixes issue #284498

The issue was caused by the fact that the copyAllCommand wasn't considering whether the click was done on normal searches or ai searches.

Test it:

Go to search -> AI Search
Search for anything
Right click on any result and select 'Copy All'
Paste the copied contents into a file and check if they correspond.

Copilot AI review requested due to automatic review settings December 26, 2025 13:43
Copy link
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

This PR fixes issue #284498 where the "Copy All" command in the search view wasn't distinguishing between normal search results and AI search results. The fix ensures that when copying all results, the command respects the context (AI or regular search) of the clicked element.

Key Changes:

  • Modified copyAllCommand to accept a match parameter to determine the search context
  • Added isAISearchResult helper function to identify if an element belongs to AI search results
  • Updated CopyAllCommandAction.run() to pass the match parameter through to the command
Comment on lines 180 to 193
async function copyAllCommand(accessor: ServicesAccessor, match: RenderableMatch | undefined) {
const viewsService = accessor.get(IViewsService);
const clipboardService = accessor.get(IClipboardService);
const labelService = accessor.get(ILabelService);

const searchView = getSearchView(viewsService);
if (searchView) {
const root = searchView.searchResult;
const isAISearchElement = isAISearchResult(match);

const text = allFolderMatchesToString(root.folderMatches(), labelService);
const text = allFolderMatchesToString(root.folderMatches(isAISearchElement), labelService);
await clipboardService.writeText(text);
}
}
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

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

When the match parameter is undefined (e.g., when invoked without a specific context), the function should fall back to getting the selected row using getSelectedRow(), similar to copyMatchCommand(). Currently, if match is undefined, isAISearchResult(match) returns false, which means the command will always copy plain text search results even when the user is in the AI search context. This could result in copying the wrong search results.

Consider adding a fallback:

if (!match) {
    match = getSelectedRow(accessor);
}

before calling isAISearchResult(match).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants