From b63b0c3c8d4646a162e782f1f5b4f56fbf14158a Mon Sep 17 00:00:00 2001 From: dobbydobap Date: Tue, 7 Jul 2026 11:32:26 +0530 Subject: [PATCH] Keep focus on the next resource when staging in the SCM view --- src/vs/workbench/contrib/scm/browser/scmViewPane.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index a2887d47f25215..47885521f10575 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -1983,6 +1983,12 @@ export class SCMViewPane extends ViewPane { async () => { const focusedInput = this.inputRenderer.getFocusedInput(); + const treeHasDomFocus = isActiveElement(this.tree.getHTMLElement()); + const focus = this.tree.getFocus().at(0); + const nextFocus = treeHasDomFocus && focus && isSCMResource(focus) + ? this.tree.navigate(focus).next() ?? this.tree.navigate(focus).previous() ?? focus.resourceGroup + : undefined; + if (element && this.tree.hasNode(element)) { // Refresh specific repository await this.tree.updateChildren(element); @@ -1995,6 +2001,13 @@ export class SCMViewPane extends ViewPane { this.inputRenderer.getRenderedInputWidget(focusedInput)?.focus(); } + if (focus && nextFocus && !this.tree.hasNode(focus) && this.tree.hasNode(nextFocus)) { + this.tree.setFocus([nextFocus]); + if (treeHasDomFocus) { + this.tree.domFocus(); + } + } + this.updateScmProviderContextKeys(); this.updateRepositoryCollapseAllContextKeys(); }));