From 56ab37534b9fa32e9e621b351bdc0be511a62532 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 24 Mar 2021 19:44:37 +0300 Subject: [PATCH] IDEA-264890: Recent Files / Switcher chooses the first item by default GitOrigin-RevId: 2bd9ad2646c105c5965c6c86d637472388cb319f --- .../src/com/intellij/ide/actions/Switcher.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java index a893e51493a0..2f7483152655 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/Switcher.java @@ -232,7 +232,6 @@ public final class Switcher extends BaseSwitcherAction { toolWindows.addKeyListener(onKeyRelease); ScrollingUtil.installActions(toolWindows); ListHoverListener.DEFAULT.addTo(toolWindows); - ScrollingUtil.ensureSelectionExists(toolWindows); myClickListener.installOn(toolWindows); final List filesToShow = getFilesToShow(project, collectFiles(project, onlyEdited), @@ -280,14 +279,14 @@ public final class Switcher extends BaseSwitcherAction { ScrollingUtil.installActions(files); ListHoverListener.DEFAULT.addTo(files); myClickListener.installOn(files); - ScrollingUtil.ensureSelectionExists(files); if (filesModel.getSize() > 0) { addToCenter(new SwitcherScrollPane(files, JBUI.CurrentTheme.Popup.separatorColor())); int selectionIndex = getFilesSelectedIndex(project, files, forward); - if (selectionIndex > -1) { - files.setSelectedIndex(selectionIndex); - } + files.setSelectedIndex(selectionIndex > -1 ? selectionIndex : 0); + } + else { + ScrollingUtil.ensureSelectionExists(toolWindows); } addToTop(header); addToLeft(new SwitcherScrollPane(toolWindows, null));