From 8b20807c1b350494f1a4caed45ae8f6a1e68d8a3 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Wed, 23 Nov 2022 09:09:59 -0300 Subject: [PATCH] fix history do after undo Signed-off-by: Victor Seiji Hariki Former-commit-id: de84fcb501cd576e8546abc5b1d4e42933488252 --- js/ui/history.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/ui/history.js b/js/ui/history.js index 2a2018b..9af8303 100644 --- a/js/ui/history.js +++ b/js/ui/history.js @@ -25,18 +25,26 @@ }; _commands_events.on((message) => { + if (message.action === "run") { + Array.from(historyView.children).forEach((child) => { + if ( + !commands.history.find((entry) => `hist-${entry.id}` === child.id) + ) { + console.log("Removing " + entry.id); + historyView.removeChild(child); + } + }); + } + commands.history.forEach((entry, index) => { - console.log("Inserting " + entry.id); if (!document.getElementById(`hist-${entry.id}`)) { + console.log("Inserting " + entry.id); historyView.appendChild( makeHistoryEntry(index, `hist-${entry.id}`, entry.title) ); } }); - while (historyView.children.length > commands.history.length) - historyView.removeChild(historyView.lastElementChild); - Array.from(historyView.children).forEach((child, index) => { if (index === commands.current) { child.classList.remove(["past"]);