treeview: add proper predicate for delete command

This commit is contained in:
jgmdev 2022-03-20 01:58:39 -04:00
parent c3bcf68851
commit bbac4d1560
1 changed files with 16 additions and 4 deletions

View File

@ -660,7 +660,22 @@ command.add(TreeView, {
["treeview:expand"] = function()
view:toggle_expand(true)
end,
})
local function treeitem() return view.hovered_item or view.selected_item end
command.add(
function()
return treeitem() ~= nil
and (
core.active_view == view or core.active_view == menu
or (view.toolbar and core.active_view == view.toolbar)
-- sometimes the context menu is shown on top of statusbar
or core.active_view == core.status_view
)
end, {
["treeview:delete"] = function()
local filename = treeitem().abs_filename
local relfilename = treeitem().filename
@ -697,13 +712,10 @@ command.add(TreeView, {
end
end
)
end,
end
})
local function treeitem() return view.hovered_item or view.selected_item end
command.add(function() return treeitem() ~= nil end, {
["treeview:rename"] = function()
local old_filename = treeitem().filename