Skip to content

Commit a84b451

Browse files
committed
fix: only allow delete on files and directories, fixes #478
1 parent 9acf8ac commit a84b451

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,17 @@ end
326326
M.delete = function(state, callback)
327327
local tree = state.tree
328328
local node = tree:get_node()
329-
if node.type == "message" then
330-
return
329+
if node.type == "file" or node.type == "directory" then
330+
fs_actions.delete_node(node.path, callback)
331+
else
332+
log.warn("The `delete` command can only be used on files and directories")
331333
end
332-
fs_actions.delete_node(node.path, callback)
333334
end
334335

335336
M.delete_visual = function(state, selected_nodes, callback)
336337
local paths_to_delete = {}
337338
for _, node_to_delete in pairs(selected_nodes) do
338-
if node_to_delete.type ~= "message" then
339+
if node_to_delete.type == "file" or node_to_delete.type == "directory" then
339340
table.insert(paths_to_delete, node_to_delete.path)
340341
end
341342
end

0 commit comments

Comments
 (0)