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 6585b4a..6c476f6 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 @@ -70,15 +70,20 @@ internal object VimTreeNavigation { val path = tree.selectionPath ?: return if (tree.isExpanded(path)) { - tree.collapsePath(path) + collapseAndScroll(tree, path) } else { val parentPath = path.parentPath if (parentPath.parentPath != null || tree.isRootVisible) { - tree.collapsePath(parentPath) + collapseAndScroll(tree, parentPath) } } } + + private fun collapseAndScroll(tree: JTree, path: TreePath) { + tree.collapsePath(path) + tree.scrollRowToVisible(tree.getRowForPath(path)) + } } private data object ExpandTreeNodeChildrenToNextLevel : ActionNode<VimNavigationDispatcher<JTree>> {