diff --git a/src/vs/workbench/contrib/search/browser/searchView.ts b/src/vs/workbench/contrib/search/browser/searchView.ts index 697012dbc5a..2d6479dec60 100644 --- a/src/vs/workbench/contrib/search/browser/searchView.ts +++ b/src/vs/workbench/contrib/search/browser/searchView.ts @@ -971,12 +971,18 @@ export class SearchView extends ViewPane { e.browserEvent.preventDefault(); e.browserEvent.stopPropagation(); + const context = this.tree.getSelection() || e.element; + let arg; + if (context && context.length > 0) { + arg = e.element; + } + this.contextMenuService.showContextMenu({ menuId: MenuId.SearchContext, - menuActionOptions: { shouldForwardArgs: true }, + menuActionOptions: { shouldForwardArgs: true, arg }, contextKeyService: this.contextKeyService, getAnchor: () => e.anchor, - getActionsContext: () => e.element, + getActionsContext: () => context, }); }