Skip to content

Commit bfeb7cb

Browse files
committed
fixes #90893
1 parent 55307ef commit bfeb7cb

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

src/vs/workbench/browser/actions/listCommands.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,35 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
736736
}
737737
});
738738

739+
KeybindingsRegistry.registerCommandAndKeybindingRule({
740+
id: 'list.toggleSelection',
741+
weight: KeybindingWeight.WorkbenchContrib,
742+
when: WorkbenchListFocusContextKey,
743+
primary: KeyMod.CtrlCmd | KeyCode.Enter,
744+
handler: (accessor) => {
745+
const widget = accessor.get(IListService).lastFocusedList;
746+
747+
if (!widget || isLegacyTree(widget)) {
748+
return;
749+
}
750+
751+
const focus = widget.getFocus();
752+
753+
if (focus.length === 0) {
754+
return;
755+
}
756+
757+
const selection = widget.getSelection();
758+
const index = selection.indexOf(focus[0]);
759+
760+
if (index > -1) {
761+
widget.setSelection([...selection.slice(0, index), ...selection.slice(index + 1)]);
762+
} else {
763+
widget.setSelection([...selection, focus[0]]);
764+
}
765+
}
766+
});
767+
739768
KeybindingsRegistry.registerCommandAndKeybindingRule({
740769
id: 'list.toggleExpand',
741770
weight: KeybindingWeight.WorkbenchContrib,

src/vs/workbench/contrib/scm/browser/repositoryPane.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,16 @@ interface ResourceTemplate {
146146
disposables: IDisposable;
147147
}
148148

149-
class MultipleSelectionActionRunner extends ActionRunner {
149+
class RepositoryPaneActionRunner extends ActionRunner {
150150

151-
constructor(private getSelectedResources: () => (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[]) {
151+
constructor(
152+
private getSelectedResources: () => (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[],
153+
private focus: () => void
154+
) {
152155
super();
153156
}
154157

155-
runAction(action: IAction, context: ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>): Promise<any> {
158+
async runAction(action: IAction, context: ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>): Promise<any> {
156159
if (!(action instanceof MenuItemAction)) {
157160
return super.runAction(action, context);
158161
}
@@ -161,7 +164,8 @@ class MultipleSelectionActionRunner extends ActionRunner {
161164
const contextIsSelected = selection.some(s => s === context);
162165
const actualContext = contextIsSelected ? selection : [context];
163166
const args = flatten(actualContext.map(e => ResourceTree.isResourceNode(e) ? ResourceTree.collect(e) : [e]));
164-
return action.run(...args);
167+
await action.run(...args);
168+
this.focus();
165169
}
166170
}
167171

@@ -175,6 +179,7 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
175179
private labels: ResourceLabels,
176180
private actionViewItemProvider: IActionViewItemProvider,
177181
private getSelectedResources: () => (ISCMResource | IResourceNode<ISCMResource, ISCMResourceGroup>)[],
182+
private focus: () => void,
178183
private themeService: IThemeService,
179184
private menus: SCMMenus
180185
) { }
@@ -186,7 +191,7 @@ class ResourceRenderer implements ICompressibleTreeRenderer<ISCMResource | IReso
186191
const actionsContainer = append(fileLabel.element, $('.actions'));
187192
const actionBar = new ActionBar(actionsContainer, {
188193
actionViewItemProvider: this.actionViewItemProvider,
189-
actionRunner: new MultipleSelectionActionRunner(this.getSelectedResources)
194+
actionRunner: new RepositoryPaneActionRunner(this.getSelectedResources, this.focus)
190195
});
191196

192197
const decorationIcon = append(element, $('.decoration-icon'));
@@ -820,7 +825,7 @@ export class RepositoryPane extends ViewPane {
820825

821826
const renderers = [
822827
new ResourceGroupRenderer(actionViewItemProvider, this.themeService, this.menus),
823-
new ResourceRenderer(() => this.viewModel, this.listLabels, actionViewItemProvider, () => this.getSelectedResources(), this.themeService, this.menus)
828+
new ResourceRenderer(() => this.viewModel, this.listLabels, actionViewItemProvider, () => this.getSelectedResources(), () => this.tree.domFocus(), this.themeService, this.menus)
824829
];
825830

826831
const filter = new SCMTreeFilter();
@@ -1024,7 +1029,7 @@ export class RepositoryPane extends ViewPane {
10241029
getAnchor: () => e.anchor,
10251030
getActions: () => actions,
10261031
getActionsContext: () => element,
1027-
actionRunner: new MultipleSelectionActionRunner(() => this.getSelectedResources())
1032+
actionRunner: new RepositoryPaneActionRunner(() => this.getSelectedResources(), () => this.tree.domFocus())
10281033
});
10291034
}
10301035

0 commit comments

Comments
 (0)