From 030f4a15d4a2b13d3264968bf10d7b13b0c3ec97 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 3 Aug 2024 21:49:11 +0200 Subject: [PATCH] ReadHistory: On remove, trust the index from FileManagerHistory if possible (#12253) The item's idx field is based on the current view settings, so only trust it when there's no filtering or searches involved, which ensures the order matches the actual history array layout. --- frontend/apps/filemanager/filemanagerhistory.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/apps/filemanager/filemanagerhistory.lua b/frontend/apps/filemanager/filemanagerhistory.lua index d360ba744..abef55ea1 100644 --- a/frontend/apps/filemanager/filemanagerhistory.lua +++ b/frontend/apps/filemanager/filemanagerhistory.lua @@ -207,7 +207,12 @@ function FileManagerHistory:onMenuHold(item) text = _("Remove from history"), callback = function() UIManager:close(self.histfile_dialog) - require("readhistory"):removeItem(item) + -- The item's idx field is tied to the current *view*, so we can only pass it as-is when there's no filtering *at all* involved. + local index = item.idx + if self._manager.search_string or self._manager.selected_colections or self._manager.filter ~= "all" then + index = nil + end + require("readhistory"):removeItem(item, index) self._manager:updateItemTable() end, },