diff --git a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/vimNavigation/components/VimTreeNavigation.kt b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/vimNavigation/components/VimTreeNavigation.kt index 6c476f6..d952159 100644 --- a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/vimNavigation/components/VimTreeNavigation.kt +++ b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/vimNavigation/components/VimTreeNavigation.kt @@ -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)