@@ -723,17 +723,14 @@ M.toggle_directory = function(state, toggle_directory)
723723 M .toggle_node (state , toggle_directory )
724724end
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
731731local 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 ()
0 commit comments