1
0
mirror of https://github.com/chylex/IntelliJ-Keyboard-Master.git synced 2025-04-24 05:15:42 +02:00

Disable automatic tree auto-expansion in vim-style navigation

This commit is contained in:
chylex 2024-09-18 08:52:51 +02:00
parent f814ec04bd
commit 5aea7947ec
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548

View File

@ -59,7 +59,7 @@ internal object VimTreeNavigation {
tree.collapsePath(path)
}
else {
tree.expandPath(path)
runWithoutAutoExpand(tree) { tree.expandPath(path) }
}
}
}
@ -116,16 +116,6 @@ internal object VimTreeNavigation {
pathsToExpand = nextPathsToExpand
} while (pathsToExpand.isNotEmpty())
}
private inline fun runWithoutAutoExpand(tree: JTree, action: () -> Unit) {
val previousAutoExpandValue = ClientProperty.get(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED)
ClientProperty.put(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED, false)
try {
action()
} finally {
ClientProperty.put(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED, previousAutoExpandValue)
}
}
}
private data object SelectFirstSibling : ActionNode<VimNavigationDispatcher<JTree>> {
@ -166,6 +156,16 @@ internal object VimTreeNavigation {
}
}
private inline fun runWithoutAutoExpand(tree: JTree, action: () -> Unit) {
val previousAutoExpandValue = ClientProperty.get(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED)
ClientProperty.put(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED, false)
try {
action()
} finally {
ClientProperty.put(tree, DefaultTreeUI.AUTO_EXPAND_ALLOWED, previousAutoExpandValue)
}
}
private fun selectRow(tree: JTree, row: Int) {
tree.setSelectionRow(row)
tree.scrollRowToVisible(row)