From d93e5f9d972e85de410cc18dc741de4652d3bb4a Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 5 Feb 2023 22:50:11 +0100 Subject: [PATCH] Fix a few console bugs * Fix console always reclaiming focus when input field is empty. * Always clear auto complete vector once item has been selected. --- r5dev/gameui/IConsole.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/r5dev/gameui/IConsole.cpp b/r5dev/gameui/IConsole.cpp index fce85cb2..faead149 100644 --- a/r5dev/gameui/IConsole.cpp +++ b/r5dev/gameui/IConsole.cpp @@ -286,7 +286,7 @@ void CConsole::DrawSurface(void) ImGui::PushItemWidth(flFooterWidthReserve - 80); if (ImGui::InputText("##input", m_szInputBuf, IM_ARRAYSIZE(m_szInputBuf), m_nInputFlags, &TextEditCallbackStub, reinterpret_cast(this))) { - if (m_nSuggestPos != -1) + if (m_nSuggestPos > -1) { BuildInputFromSelected(m_vSuggest[m_nSuggestPos], m_svInputConVar); m_bModifyInput = true; @@ -440,7 +440,7 @@ void CConsole::SuggestPanel(void) BuildInputFromSelected(suggest, svConVar); memmove(m_szInputBuf, svConVar.data(), svConVar.size() + 1); - ResetAutoComplete(); + ClearAutoComplete(); // Mutex lock is obtained here are we modify m_vHistory // which is used in the main and render thread. @@ -481,7 +481,10 @@ bool CConsole::AutoComplete(void) // Don't suggest if user tries to assign value to ConVar or execute ConCommand. if (!m_szInputBuf[0] || strstr(m_szInputBuf, ";")) { - ResetAutoComplete(); + if (m_bSuggestActive) + { + ResetAutoComplete(); + } return false; } @@ -559,9 +562,7 @@ void CConsole::ResetAutoComplete(void) //----------------------------------------------------------------------------- void CConsole::ClearAutoComplete(void) { - m_bCanAutoComplete = false; - m_nSuggestPos = -1; - m_bSuggestUpdate = true; + ResetAutoComplete(); m_vSuggest.clear(); } @@ -969,6 +970,8 @@ int CConsole::TextEditCallback(ImGuiInputTextCallbackData* iData) { iData->InsertChars(0, m_svInputConVar.c_str()); m_svInputConVar.clear(); + + ClearAutoComplete(); } m_bModifyInput = false; }