fix: host filtering may not work

This commit is contained in:
hstyi
2025-06-16 15:11:35 +08:00
committed by hstyi
parent b4e82a4a0e
commit d3cfde5238
2 changed files with 9 additions and 2 deletions

View File

@@ -466,7 +466,7 @@ class NewHostTree : SimpleTree(), Disposable {
val nodes = getSelectionSimpleTreeNodes(true).filter { it.isFolder.not() } val nodes = getSelectionSimpleTreeNodes(true).filter { it.isFolder.not() }
if (nodes.isEmpty()) return if (nodes.isEmpty()) return
val source = if (openInNewWindow) val source = if (openInNewWindow)
TermoraFrameManager.Companion.getInstance().createWindow().apply { isVisible = true } TermoraFrameManager.getInstance().createWindow().apply { isVisible = true }
else evt.source else evt.source
nodes.map { it.host }.forEach { openHostAction.actionPerformed(OpenHostActionEvent(source, it, evt)) } nodes.map { it.host }.forEach { openHostAction.actionPerformed(OpenHostActionEvent(source, it, evt)) }
} }

View File

@@ -271,12 +271,19 @@ open class SimpleTree : JXTree() {
val nodes = mutableListOf<SimpleTreeNode<*>>() val nodes = mutableListOf<SimpleTreeNode<*>>()
val parents = paths.mapNotNull { it.lastPathComponent } val parents = paths.mapNotNull { it.lastPathComponent }
.filterIsInstance<SimpleTreeNode<*>>().toMutableList() .filterIsInstance<SimpleTreeNode<*>>().toMutableList()
val model = super.getModel()
if (include) { if (include) {
while (parents.isNotEmpty()) { while (parents.isNotEmpty()) {
val node = parents.removeFirst() val node = parents.removeFirst()
nodes.add(node) nodes.add(node)
parents.addAll(node.children().toList().filterIsInstance<SimpleTreeNode<*>>()) val count = model.getChildCount(node)
for (i in 0 until count) {
val child = model.getChild(node, i)
if (child is SimpleTreeNode<*>) {
parents.add(child)
}
}
} }
} }