From 0a83e8beb4c6425ccc94079c2ef044e2c1ac5001 Mon Sep 17 00:00:00 2001 From: hstyi Date: Mon, 12 May 2025 10:49:35 +0800 Subject: [PATCH] fix: double-click to open the host (#566) --- src/main/kotlin/app/termora/NewHostTree.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/termora/NewHostTree.kt b/src/main/kotlin/app/termora/NewHostTree.kt index 0c6ba7c..87bbd9d 100644 --- a/src/main/kotlin/app/termora/NewHostTree.kt +++ b/src/main/kotlin/app/termora/NewHostTree.kt @@ -135,10 +135,12 @@ class NewHostTree : SimpleTree() { // double click addMouseListener(object : MouseAdapter() { override fun mouseClicked(e: MouseEvent) { - if (getPathForLocation(e.x, e.y) == null) return if (doubleClickConnection && SwingUtilities.isLeftMouseButton(e) && e.clickCount % 2 == 0) { val lastNode = lastSelectedPathComponent as? HostTreeNode ?: return if (lastNode.host.protocol != Protocol.Folder) { + val path = tree.getClosestPathForLocation(e.x, e.y) ?: return + val bounds = tree.getRowBounds(tree.getRowForPath(path)) ?: return + if ((e.y >= bounds.y && e.y < (bounds.y + bounds.height)).not()) return openHostAction?.actionPerformed(OpenHostActionEvent(e.source, lastNode.host, e)) } }