IDEA-264890: Recent Files / Switcher chooses the first item by default

GitOrigin-RevId: 2bd9ad2646c105c5965c6c86d637472388cb319f
This commit is contained in:
Sergey Malenkov
2021-03-24 18:49:26 +00:00
committed by intellij-monorepo-bot
parent 675459121a
commit 56ab37534b
@@ -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<FileInfo> 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));