Skip to content

Commit 70ebc41

Browse files
authored
fix(buffers): make the parent node for terminals expandable (#1761)
1 parent 38cea2a commit 70ebc41

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lua/neo-tree/sources/common/commands.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -723,17 +723,14 @@ M.toggle_directory = function(state, toggle_directory)
723723
M.toggle_node(state, toggle_directory)
724724
end
725725

726-
---Open file or directory
726+
---Open file or expandable node
727727
---@param state table The state of the source
728728
---@param open_cmd string The vim command to use to open the file
729729
---@param toggle_directory function The function to call to toggle a directory
730730
---open/closed
731731
local open_with_cmd = function(state, open_cmd, toggle_directory, open_file)
732732
local tree = state.tree
733733
local success, node = pcall(tree.get_node, tree)
734-
if node.type == "message" then
735-
return
736-
end
737734
if not (success and node) then
738735
log.debug("Could not get node.")
739736
return
@@ -762,13 +759,13 @@ local open_with_cmd = function(state, open_cmd, toggle_directory, open_file)
762759
end
763760

764761
local config = state.config or {}
765-
if node.type ~= "directory" and config.no_expand_file ~= nil then
762+
if node.type == "file" and config.no_expand_file ~= nil then
766763
log.warn("`no_expand_file` options is deprecated, move to `expand_nested_files` (OPPOSITE)")
767764
config.expand_nested_files = not config.no_expand_file
768765
end
769-
if node.type == "directory" then
770-
M.toggle_node(state, toggle_directory)
771-
elseif node:has_children() and config.expand_nested_files and not node:is_expanded() then
766+
767+
local should_expand_file = config.expand_nested_files and not node:is_expanded()
768+
if utils.is_expandable(node) and (node.type ~= "file" or should_expand_file) then
772769
M.toggle_node(state, toggle_directory)
773770
else
774771
open()

lua/neo-tree/utils/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ M.truthy = function(value)
11271127
end
11281128

11291129
M.is_expandable = function(node)
1130-
return node.type == "directory" or node:has_children()
1130+
return node:has_children() or node.type == "directory"
11311131
end
11321132

11331133
M.windowize_path = function(path)

0 commit comments

Comments
 (0)