From 0b811c70fd93194d3df401bec770a2a6cef85a0c Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Sun, 7 Jan 2024 02:05:52 -0800 Subject: [PATCH] don't add duplicates of last remembered string in chat history --- srcjs/stendhal/ui/component/ChatInputComponent.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/srcjs/stendhal/ui/component/ChatInputComponent.ts b/srcjs/stendhal/ui/component/ChatInputComponent.ts index b7c98fbdcd..7ec054098a 100644 --- a/srcjs/stendhal/ui/component/ChatInputComponent.ts +++ b/srcjs/stendhal/ui/component/ChatInputComponent.ts @@ -133,6 +133,13 @@ export class ChatInputComponent extends Component { } public remember(text: string) { + // don't add duplicates of last remembered string + if (this.history.length > 0 && text === this.history[this.history.length-1]) { + this.historyIndex = this.history.length; + config.set("chat.history.index", this.historyIndex); + return; + } + if (this.history.length > 100) { this.history.shift(); }