From b30bbdeba9afbf7003e56dac1d56c014e834d458 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 30 Oct 2020 11:09:06 +0100 Subject: [PATCH] fixes #71315 --- .../files/browser/views/explorerView.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/views/explorerView.ts b/src/vs/workbench/contrib/files/browser/views/explorerView.ts index 91e73be6167..3db50a8a903 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerView.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerView.ts @@ -590,14 +590,20 @@ export class ExplorerView extends ViewPane { return; } const compressedController = this.renderer.getCompressedNavigationController(focus[0]) || this.renderer.getCompressedNavigationController(item); - const itemsCompressedTogether = compressedController && (compressedController.items.indexOf(focus[0]) >= 0) && (compressedController.items.indexOf(item) >= 0); + const indexOfItem = compressedController?.items.indexOf(item) || -1; + const itemsCompressedTogether = compressedController && (compressedController.items.indexOf(focus[0]) >= 0) && (indexOfItem >= 0); if (focus[0] === item || itemsCompressedTogether) { - this.tree.focusNext(); - const newFocus = this.tree.getFocus(); - if (newFocus.length === 1 && newFocus[0] === item) { - // There was no next item to focus, focus the previous one - this.tree.focusPrevious(); + if (itemsCompressedTogether && indexOfItem > 0 && item.parent) { + // In case of compact items just focus the parent if it is part of the compact item. So the focus stays + this.tree.setFocus([item.parent]); + } else { + this.tree.focusNext(); + const newFocus = this.tree.getFocus(); + if (newFocus.length === 1 && newFocus[0] === item) { + // There was no next item to focus, focus the previous one + this.tree.focusPrevious(); + } } } }