Skip to content

Commit

Permalink
Fix treeview multiselect right-click issue (microsoft#210910)
Browse files Browse the repository at this point in the history
* Treeview with multiselect mishandles right-click outside the selection
Fixes microsoft#208849

* No need to clear context

* Do reset context if target is outside selection
  • Loading branch information
alexr00 authored and sergioengineer committed Apr 23, 2024
1 parent 803c037 commit 8981143
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,10 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
event.stopPropagation();

this.tree!.setFocus([node]);
const selected = this.canSelectMany ? this.getSelection() : [];
selected.unshift(node);
let selected = this.canSelectMany ? this.getSelection() : [];
if (selected.length === 0) {
selected = [node];
}
const actions = treeMenus.getResourceContextActions(selected);
if (!actions.length) {
return;
Expand Down Expand Up @@ -1565,8 +1567,8 @@ class MultipleSelectionActionRunner extends ActionRunner {
});
}

if (!actionInSelected) {
selectionHandleArgs = undefined;
if (!actionInSelected && selectionHandleArgs && selectionHandleArgs.length > 0) {
context = selectionHandleArgs[0];
}

await action.run(context, selectionHandleArgs);
Expand Down

0 comments on commit 8981143

Please sign in to comment.