@@ -29,16 +29,14 @@ local function get_num_nodes(iter)
2929 return i
3030end
3131
32- --- @param has_children boolean
33- --- @param absolute_path string
34- --- @param name string
32+ --- @param node Node
3533--- @return string
36- local function get_containing_folder (has_children , absolute_path , name )
37- if has_children then
38- return utils .path_add_trailing (absolute_path )
34+ local function get_containing_folder (node )
35+ if node . nodes ~= nil then
36+ return utils .path_add_trailing (node . absolute_path )
3937 end
40- local node_name_size = # (name or " " )
41- return absolute_path :sub (0 , - node_name_size - 1 )
38+ local node_name_size = # (node . name or " " )
39+ return node . absolute_path :sub (0 , - node_name_size - 1 )
4240end
4341
4442--- @param node Node | nil
@@ -48,15 +46,19 @@ function M.fn(node)
4846 return
4947 end
5048
51- node = node and node :last_group_node ()
52-
53- local containing_folder
5449 if not node or node .name == " .." then
55- containing_folder = get_containing_folder (core .get_explorer ().nodes ~= nil , cwd , " " )
50+ node = {
51+ absolute_path = cwd ,
52+ name = " " ,
53+ nodes = core .get_explorer ().nodes ,
54+ open = true ,
55+ }
5656 else
57- containing_folder = get_containing_folder ( node . nodes ~= nil , node . absolute_path , node . name )
57+ node = node : last_group_node ( )
5858 end
5959
60+ local containing_folder = get_containing_folder (node )
61+
6062 local input_opts = {
6163 prompt = " Create file " ,
6264 default = containing_folder ,
0 commit comments