Skip to content

Commit

Permalink
fix(neo-tree): improve h and l navigation edge cases for empty di…
Browse files Browse the repository at this point in the history
…rectories and nested files
  • Loading branch information
mehalter committed Apr 1, 2024
1 parent bea5d52 commit f7f3204
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lua/astronvim/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,25 @@ return {
end,
parent_or_close = function(state)
local node = state.tree:get_node()
if (node.type == "directory" or node:has_children()) and node:is_expanded() then
if node:has_children() and node:is_expanded() then
state.commands.toggle_node(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_parent_id())
end
end,
child_or_open = function(state)
local node = state.tree:get_node()
if node.type == "directory" or node:has_children() then
if node:has_children() then
if not node:is_expanded() then -- if unexpanded, expand
state.commands.toggle_node(state)
else -- if expanded and has children, seleect the next child
require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1])
if node.type == "file" then
state.commands.open(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1])
end
end
else -- if not a directory just open it
else -- if has no children
state.commands.open(state)
end
end,
Expand Down

0 comments on commit f7f3204

Please sign in to comment.