Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix buffer delete mode not persisting removals #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions lua/arrow/buffer_persist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function M.sync_buffer_bookmarks(bufnr)
file:write(json.encode(M.local_bookmarks[bufnr]))
end
file:flush()
file:close()
file:close()

M.last_sync_bookmarks[bufnr] = M.local_bookmarks[bufnr]
notify()
Expand Down Expand Up @@ -159,10 +159,25 @@ function M.remove(index, bufnr)
return
end

if M.local_bookmarks[bufnr][index] == nil then
local to_remove = {}

if type(index) == "table" then
for _, i in ipairs(index) do
if M.local_bookmarks[bufnr][i] ~= nil then
table.insert(to_remove, i)
end
end
else
to_remove = { index }
end

if #to_remove == 0 then
return
end
table.remove(M.local_bookmarks[bufnr], index)

for _, i in ipairs(to_remove) do
table.remove(M.local_bookmarks[bufnr], i)
end

M.sync_buffer_bookmarks(bufnr)
end
Expand Down
4 changes: 1 addition & 3 deletions lua/arrow/buffer_ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ end
local function delete_marks_from_delete_mode(call_buffer)
local reversely_sorted_to_delete = vim.fn.reverse(vim.fn.sort(to_delete))

for _, index in ipairs(reversely_sorted_to_delete) do
persist.remove(index, call_buffer)
end
persist.remove(reversely_sorted_to_delete, call_buffer)
end

local function after_close(call_buffer)
Expand Down