From b4ead51f271ab72928b8cb331c837a801e313c7e Mon Sep 17 00:00:00 2001 From: Sergei Tachenov Date: Tue, 10 Dec 2024 10:47:07 +0200 Subject: [PATCH] IJPL-49322 Automatically select the first Project View item on show This functionality was disabled along with the first item expansion for the case when there's a restored state. This makes sense for expansion, but not for selection, as the saved state doesn't include selection anyway. For the New Element button this became sort of a big deal, as it makes the button disabled on startup. Fix by always selecting the first element on first show, but not expanding anything in case there's a restored non-empty state. GitOrigin-RevId: 64365de4607037d9ea2951daf072edd4b4fd4daf --- .../com/intellij/ide/projectView/impl/ProjectViewImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index c22722eabf75..b5f106257977 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -635,7 +635,10 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo JTree tree = pane.getTree(); if (tree != null && projectView instanceof ProjectViewImpl impl && impl.firstShow) { impl.firstShow = false; - if (!pane.myNonEmptyTreeStateRestored) { + if (pane.myNonEmptyTreeStateRestored) { + TreeUtil.promiseSelectFirst(tree); + } + else { TreeUtil.promiseSelectFirst(tree).onSuccess(tree::expandPath); } }