From 0044e6fc551462131fdae9766993b450833983d0 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Wed, 3 Dec 2014 13:05:05 +0300 Subject: [PATCH] diff: select all root nodes by default better fix for e770f02 --- .../openapi/vcs/changes/ui/ChangesTreeList.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java index 56dd73007946..b5a52c700ef0 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/ChangesTreeList.java @@ -430,7 +430,17 @@ public abstract class ChangesTreeList extends JPanel implements TypeSafeDataP myList.setSelectedIndex(listSelection); myList.ensureIndexIsVisible(listSelection); - if (scrollRow >= 0) { + if (scrollRow == -1) { + TreeNode root = (TreeNode)model.getRoot(); + int childrenCount = root.getChildCount(); + TreePath[] selected = new TreePath[childrenCount]; + for (int i = 0; i < childrenCount; i++) { + TreeNode child = root.getChildAt(i); + // reverse order, because the last one will become "current" node. And we want it to be the first one. + selected[childrenCount - i - 1] = new TreePath(model.getPathToRoot(child)); + } + myTree.setSelectionPaths(selected); + } else { myTree.setSelectionRow(scrollRow); } TreeUtil.showRowCentered(myTree, scrollRow, false);