From 5212ea9c1736268f2c77e8e01d768eda2e84782e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ska=C5=82ka?= Date: Fri, 10 May 2024 13:53:58 +0200 Subject: [PATCH] Fix history undo cycle when adding the same element --- src/web/InputHistory.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/web/InputHistory.ts b/src/web/InputHistory.ts index b9b55dc1..1ee6fa6d 100644 --- a/src/web/InputHistory.ts +++ b/src/web/InputHistory.ts @@ -69,9 +69,9 @@ export default class InputHistory { } add(text: string, cursorPosition: number): void { - if (this.items.length > 0) { - const lastItem = this.items[this.items.length - 1]; - if (lastItem && text === lastItem.text) { + if (this.historyIndex + 1 < this.items.length) { + const nextItem = this.items[this.historyIndex + 1]; + if (nextItem && text === nextItem.text) { this.historyIndex = this.items.length - 1; return; }