refactor(#2830): multi instance nvim-tree.marks (#2838)

refactor(#2380): multi instance nvim-tree.marks
This commit is contained in:
Alexander Courtis
2024-07-21 16:12:42 +10:00
committed by GitHub
parent 48a9290757
commit 4e396b2624
9 changed files with 135 additions and 66 deletions

View File

@@ -1,4 +1,3 @@
local marks = require "nvim-tree.marks"
local utils = require "nvim-tree.utils"
local remove_file = require "nvim-tree.actions.fs.trash"
local notify = require "nvim-tree.notify"
@@ -14,12 +13,17 @@ local function do_trash(nodes)
for _, node in pairs(nodes) do
remove_file.remove(node)
end
marks.clear_marks()
end
function M.bulk_trash()
local nodes = marks.get_marks()
---@param explorer Explorer
function M.bulk_trash(explorer)
if not explorer then
return
end
local marks = explorer.marks
local nodes = marks:get_marks()
if not nodes or #nodes == 0 then
notify.warn "No bookmarks to trash."
return
@@ -32,10 +36,12 @@ function M.bulk_trash()
utils.clear_prompt()
if item_short == "y" then
do_trash(nodes)
marks:clear_marks()
end
end)
else
do_trash(nodes)
marks:clear_marks()
end
end