treeview: add proper predicate for delete command
This commit is contained in:
parent
c3bcf68851
commit
bbac4d1560
|
@ -660,7 +660,22 @@ command.add(TreeView, {
|
||||||
["treeview:expand"] = function()
|
["treeview:expand"] = function()
|
||||||
view:toggle_expand(true)
|
view:toggle_expand(true)
|
||||||
end,
|
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()
|
["treeview:delete"] = function()
|
||||||
local filename = treeitem().abs_filename
|
local filename = treeitem().abs_filename
|
||||||
local relfilename = treeitem().filename
|
local relfilename = treeitem().filename
|
||||||
|
@ -697,13 +712,10 @@ command.add(TreeView, {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
local function treeitem() return view.hovered_item or view.selected_item end
|
|
||||||
|
|
||||||
|
|
||||||
command.add(function() return treeitem() ~= nil end, {
|
command.add(function() return treeitem() ~= nil end, {
|
||||||
["treeview:rename"] = function()
|
["treeview:rename"] = function()
|
||||||
local old_filename = treeitem().filename
|
local old_filename = treeitem().filename
|
||||||
|
|
Loading…
Reference in New Issue