diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 387ca9cb18..8a1412ac81 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -192,6 +192,7 @@ server.threads = "6" ; Enough for the browser's parallel co [console] font = "mono-10" history.size = 200 +history.ignore_duplicates = true ; Don't store consecutive identical commands twice [hotkey] ; Each one of the specified keys will trigger the action on the left diff --git a/source/ps/CConsole.cpp b/source/ps/CConsole.cpp index 175e43efd9..b3ede4aa48 100644 --- a/source/ps/CConsole.cpp +++ b/source/ps/CConsole.cpp @@ -85,6 +85,7 @@ void CConsole::Init() { // Initialise console history file m_MaxHistoryLines = g_ConfigDB.Get("console.history.size", 200); + m_HistoryIgnoreDuplicates = g_ConfigDB.Get("console.history.ignore_duplicates", true); m_consoleFont = g_ConfigDB.Get("console.font", std::string{"mono-10"}); m_HistoryFile = L"config/console.txt"; @@ -577,9 +578,12 @@ void CConsole::ProcessBuffer(const wchar_t* szLine) ENSURE(wcslen(szLine) < CONSOLE_BUFFER_SIZE); - m_BufHistory.push_front(szLine); - SaveHistory(); // Do this each line for the moment; if a script causes - // a crash it's a useful record. + if (!m_HistoryIgnoreDuplicates || m_BufHistory.front() != szLine) + { + m_BufHistory.push_front(szLine); + SaveHistory(); // Do this each line for the moment; if a script causes + // a crash it's a useful record. + } // Process it as JavaScript std::shared_ptr pScriptInterface = g_GUI->GetActiveGUI()->GetScriptInterface(); diff --git a/source/ps/CConsole.h b/source/ps/CConsole.h index 40b7ec7a60..e6e4ed5d3c 100644 --- a/source/ps/CConsole.h +++ b/source/ps/CConsole.h @@ -103,6 +103,7 @@ private: VfsPath m_HistoryFile; int m_MaxHistoryLines; + bool m_HistoryIgnoreDuplicates; std::string m_consoleFont; bool m_Visible; // console is to be drawn