From bea6b60cd195a84334aef1e0c8e7e1c8c633e87e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Wed, 29 Sep 2021 16:49:26 +0200 Subject: [PATCH] fixes #131938 --- src/vs/base/browser/ui/list/listWidget.ts | 18 ++++++++++++++---- .../workbench/browser/actions/listCommands.ts | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index 367a065e20b..3331c66f231 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -307,7 +307,9 @@ class KeyboardController implements IDisposable { e.preventDefault(); e.stopPropagation(); this.list.focusPrevious(1, false, e.browserEvent); - this.list.reveal(this.list.getFocus()[0]); + const el = this.list.getFocus()[0]; + this.list.setAnchor(el); + this.list.reveal(el); this.view.domNode.focus(); } @@ -315,7 +317,9 @@ class KeyboardController implements IDisposable { e.preventDefault(); e.stopPropagation(); this.list.focusNext(1, false, e.browserEvent); - this.list.reveal(this.list.getFocus()[0]); + const el = this.list.getFocus()[0]; + this.list.setAnchor(el); + this.list.reveal(el); this.view.domNode.focus(); } @@ -323,7 +327,9 @@ class KeyboardController implements IDisposable { e.preventDefault(); e.stopPropagation(); this.list.focusPreviousPage(e.browserEvent); - this.list.reveal(this.list.getFocus()[0]); + const el = this.list.getFocus()[0]; + this.list.setAnchor(el); + this.list.reveal(el); this.view.domNode.focus(); } @@ -331,7 +337,9 @@ class KeyboardController implements IDisposable { e.preventDefault(); e.stopPropagation(); this.list.focusNextPage(e.browserEvent); - this.list.reveal(this.list.getFocus()[0]); + const el = this.list.getFocus()[0]; + this.list.setAnchor(el); + this.list.reveal(el); this.view.domNode.focus(); } @@ -339,6 +347,7 @@ class KeyboardController implements IDisposable { e.preventDefault(); e.stopPropagation(); this.list.setSelection(range(this.list.length), e.browserEvent); + this.list.setAnchor(undefined); this.view.domNode.focus(); } @@ -347,6 +356,7 @@ class KeyboardController implements IDisposable { e.preventDefault(); e.stopPropagation(); this.list.setSelection([], e.browserEvent); + this.list.setAnchor(undefined); this.view.domNode.focus(); } } diff --git a/src/vs/workbench/browser/actions/listCommands.ts b/src/vs/workbench/browser/actions/listCommands.ts index 29955f9167c..9928f1b0cf7 100644 --- a/src/vs/workbench/browser/actions/listCommands.ts +++ b/src/vs/workbench/browser/actions/listCommands.ts @@ -61,6 +61,7 @@ async function navigate(widget: WorkbenchListWidget | undefined, updateFocusFn: widget.reveal(listFocus[0]); } + widget.setAnchor(listFocus[0]); ensureDOMFocus(widget); } @@ -404,6 +405,7 @@ function selectElement(accessor: ServicesAccessor, retainCurrentFocus: boolean): if (focused instanceof List || focused instanceof PagedList || focused instanceof Table) { const list = focused; list.setSelection(list.getFocus(), fakeKeyboardEvent); + list.setAnchor(list.getFocus()[0]); } // Trees @@ -425,6 +427,7 @@ function selectElement(accessor: ServicesAccessor, retainCurrentFocus: boolean): } } tree.setSelection(focus, fakeKeyboardEvent); + tree.setAnchor(focus[0]); } }