Skip to content

Commit 98351c9

Browse files
author
chenyang
committed
搜索找到的条目准确得放到第一项
1 parent c792e51 commit 98351c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/com/shuzijun/leetcode/plugin/listener/QueryKeyListener.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ public void keyPressed(KeyEvent e) {
8080
}
8181
DefaultMutableTreeNode temp = (DefaultMutableTreeNode) all.getChildAt(i);
8282
if (temp.getUserObject().toString().toUpperCase().replace(" ","").contains(selectText.toUpperCase().replace(" ",""))) {
83-
tree.setSelectionPath(new TreePath(temp.getPath()));
84-
Point point = new Point(0, i < 3 ? 0 : (i - 3) * tree.getRowHeight());
83+
TreePath toShowPath = new TreePath(temp.getPath());
84+
tree.setSelectionPath(toShowPath);
85+
Rectangle bounds = tree.getPathBounds(toShowPath);
86+
Point point = new Point(0, (int) bounds.getY());
8587
viewport.setViewPosition(point);
8688
return;
8789
}
8890
}
8991
MessageUtils.showMsg(toolWindow.getContentManager().getComponent(), MessageType.INFO, "info", "not find next");
90-
return;
9192
}
9293
}
9394

0 commit comments

Comments
 (0)