diff --git a/src/display/editor/tools.js b/src/display/editor/tools.js index 63e078c63..21955b292 100644 --- a/src/display/editor/tools.js +++ b/src/display/editor/tools.js @@ -108,6 +108,11 @@ class CommandManager { const save = { cmd, undo, type }; if (this.#position === -1) { + if (this.#commands.length > 0) { + // All the commands have been undone and then a new one is added + // hence we clear the queue. + this.#commands.length = 0; + } this.#position = 0; this.#commands.push(save); return;