From cfd98807d7387495822f86fe3d94e3c6f95149c5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 5 Sep 2022 08:24:48 +1000 Subject: [PATCH] GUI: Avoid duplicate entries in input log, to simplify navigation through input history --- GUI/Window/Window.Main.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/GUI/Window/Window.Main.cs b/GUI/Window/Window.Main.cs index a6149291c..48046d7e1 100644 --- a/GUI/Window/Window.Main.cs +++ b/GUI/Window/Window.Main.cs @@ -109,15 +109,22 @@ namespace MCGalaxy.Gui { main_txtInput.SelectionLength = 0; main_txtInput.SelectionStart = main_txtInput.Text.Length; } + + void AddInputLog(string text) { + // Simplify navigating through input history by not logging duplicate entries + if (inputLog.Count > 0 && text == inputLog[0]) return; + + inputLog.Insert(0, text); + if (inputLog.Count > 20) + inputLog.RemoveAt(20); + } void InputText() { string text = main_txtInput.Text; if (text.Length == 0) return; - - inputLog.Insert(0, text); - if (inputLog.Count > 20) - inputLog.RemoveAt(20); - + AddInputLog(text); + + if (text == "/") { UIHelpers.RepeatCommand(); } else if (text[0] == '/' && text.Length > 1 && text[1] == '/') {