Skip to content

Commit 7db3638

Browse files
committed
refactor: change empty root without label fix
1 parent 2223f87 commit 7db3638

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lua/nvim-tree/api.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ local function wrap(f)
4141
end
4242

4343
--- Inject the node as the first argument if absent.
44-
--- f function to invoke
45-
local function wrap_node(f)
44+
---@param fn function function to invoke
45+
---@param skip_if_nil_node boolean? Should skip fn execution if there is no node
46+
local function wrap_node(fn, skip_if_nil_node)
4647
return function(node, ...)
4748
node = node or require("nvim-tree.lib").get_node_at_cursor()
48-
if node then
49-
f(node, ...)
49+
if skip_if_nil_node or node then
50+
fn(node, ...)
5051
end
5152
end
5253
end
@@ -136,7 +137,7 @@ Api.tree.is_tree_buf = wrap(require("nvim-tree.utils").is_nvim_tree_buf)
136137

137138
Api.tree.is_visible = wrap(require("nvim-tree.view").is_visible)
138139

139-
Api.fs.create = wrap_node(require("nvim-tree.actions.fs.create-file").fn)
140+
Api.fs.create = wrap_node(require("nvim-tree.actions.fs.create-file").fn, true)
140141
Api.fs.remove = wrap_node(require("nvim-tree.actions.fs.remove-file").fn)
141142
Api.fs.trash = wrap_node(require("nvim-tree.actions.fs.trash").fn)
142143
Api.fs.rename_node = wrap_node(require("nvim-tree.actions.fs.rename-file").fn ":t")

0 commit comments

Comments
 (0)