From 65cbf7f17cfd399433114caba05bfb32f9d74034 Mon Sep 17 00:00:00 2001 From: Kindi Date: Tue, 14 Mar 2023 19:10:00 +0800 Subject: [PATCH] skip reading if retrievalLimit is 0 --- apps/openmw/mwgui/console.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index f87e560a2a..09790e3ed2 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -709,20 +709,21 @@ namespace MWGui const auto filePath = mCfgMgr.getUserConfigPath() / "console_history.txt"; const size_t retrievalLimit = Settings::Manager::getSize("console history buffer size", "General"); - std::ifstream historyFile(filePath); - std::string line; - // Read the previous session's commands from the file - while (std::getline(historyFile, line)) + if (retrievalLimit > 0) { - // Truncate the list if it exceeds the retrieval limit - if (mCommandHistory.size() >= retrievalLimit) - mCommandHistory.pop_front(); - mCommandHistory.push_back(line); + std::ifstream historyFile(filePath); + std::string line; + while (std::getline(historyFile, line)) + { + // Truncate the list if it exceeds the retrieval limit + if (mCommandHistory.size() >= retrievalLimit) + mCommandHistory.pop_front(); + mCommandHistory.push_back(line); + } + historyFile.close(); } - historyFile.close(); - mCurrent = mCommandHistory.end(); try {