Skip to content

Commit

Permalink
Fix history undo cycle when adding the same element
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed May 10, 2024
1 parent e42a8f1 commit 5212ea9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/web/InputHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5212ea9

Please sign in to comment.