From 61171cbc8aa00688b20e16a7354329a50552889a Mon Sep 17 00:00:00 2001 From: Diogo Duarte Date: Fri, 19 Apr 2024 13:58:52 +0100 Subject: [PATCH] remove the indexes entry when deleting bookmarks --- init.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 0b8860e..53236f2 100644 --- a/init.lua +++ b/init.lua @@ -145,7 +145,14 @@ local delete_bookmark = ya.sync(function(state, idx) _send_notification(message) end - table.remove(state.bookmarks, idx) + state.bookmarks[idx] = nil + -- remove the indexes entry for the bookmark + for key, value in pairs(state.indexes) do + if value == idx then + state.indexes[key] = nil + break + end + end if state.persist then _save_state(state.bookmarks, state.indexes) @@ -154,9 +161,10 @@ end) local delete_all_bookmarks = ya.sync(function(state) state.bookmarks = nil + state.indexes = nil if state.persist then - _save_state(nil) + _save_state(nil, nil) end if state.notify and state.notify.enable then