Don't update every frame

Don't update completion callback every frame, only when the input has changed.
This commit is contained in:
Kawe Mazidjatari 2023-02-05 21:10:39 +01:00
parent a8ef2b74cd
commit 116d2acae8

View File

@ -478,13 +478,6 @@ void CConsole::SuggestPanel(void)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool CConsole::AutoComplete(void) bool CConsole::AutoComplete(void)
{ {
// Show ConVar/ConCommand suggestions when something has been entered.
if (!m_szInputBuf[0])
{
ResetAutoComplete();
return false;
}
// Don't suggest if user tries to assign value to ConVar or execute ConCommand. // Don't suggest if user tries to assign value to ConVar or execute ConCommand.
if (!m_szInputBuf[0] || strstr(m_szInputBuf, ";")) if (!m_szInputBuf[0] || strstr(m_szInputBuf, ";"))
{ {
@ -496,18 +489,12 @@ bool CConsole::AutoComplete(void)
{ {
if (m_bCanAutoComplete) if (m_bCanAutoComplete)
{ {
m_bCanAutoComplete = false;
FindFromPartial(); FindFromPartial();
} }
if (m_vSuggest.empty())
{
ResetAutoComplete();
return false;
} }
} else if (m_bCanAutoComplete) // Command completion callback.
else // Command completion callback.
{ {
m_vSuggest.clear(); ClearAutoComplete();
string svCommand; string svCommand;
for (size_t i = 0; i < sizeof(m_szInputBuf); i++) for (size_t i = 0; i < sizeof(m_szInputBuf); i++)
@ -546,6 +533,12 @@ bool CConsole::AutoComplete(void)
} }
} }
if (m_vSuggest.empty())
{
ResetAutoComplete();
return false;
}
m_bSuggestActive = true; m_bSuggestActive = true;
return true; return true;
} }