From 3c10c71a9117e9c61139a23b2aeda64162ca86d9 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 27 Jul 2022 23:23:28 +0200 Subject: [PATCH] [Editor] Reset the queue when a command is added after having undone all the commands --- src/display/editor/tools.js | 5 +++++ 1 file changed, 5 insertions(+) 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;