Skip adding entry to history if it matches latest entry

master
d4vid 4 months ago
parent ce20d2aa12
commit 9d03817f77

@ -1,7 +1,7 @@
ID: D4VID_ConsoleImprovements
Name: ConsoleImprovements
Author: D4VID
Version: 1.0.0
Version: 1.1.0
Priority: 0
ClientOnly: true
Dependencies:

@ -83,6 +83,13 @@ namespace ConsoleImprovements.Client {
// ReSharper disable once InconsistentNaming
public static bool HookCommandSubmit(Console __instance, ref string line) {
_command = null; // Clear the command pointer
// Skip adding the line to the history if it matches the last item
if (_history.Count > 0 && line == _history.First!.Value) {
return true;
}
// Keep the set max number of entries in the history
if (_history.Count >= HistLength) {
_history.RemoveLast();
@ -90,8 +97,6 @@ namespace ConsoleImprovements.Client {
_history.AddFirst(line);
_command = null; // Clear the command pointer
return true; // Resume original functionality
}
}

Loading…
Cancel
Save