@@ -29,16 +29,14 @@ local function get_num_nodes(iter)
29
29
return i
30
30
end
31
31
32
- --- @param has_children boolean
33
- --- @param absolute_path string
34
- --- @param name string
32
+ --- @param node Node
35
33
--- @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 )
39
37
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 )
42
40
end
43
41
44
42
--- @param node Node | nil
@@ -48,15 +46,19 @@ function M.fn(node)
48
46
return
49
47
end
50
48
51
- node = node and node :last_group_node ()
52
-
53
- local containing_folder
54
49
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
+ }
56
56
else
57
- containing_folder = get_containing_folder ( node . nodes ~= nil , node . absolute_path , node . name )
57
+ node = node : last_group_node ( )
58
58
end
59
59
60
+ local containing_folder = get_containing_folder (node )
61
+
60
62
local input_opts = {
61
63
prompt = " Create file " ,
62
64
default = containing_folder ,
0 commit comments