mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
CConsole: fix bug where history scrolling did not work even when input was empty
* Reset when buffer is empty. * Show suggestions when only 1 character has been entered.
This commit is contained in:
parent
900cc4dd9a
commit
28ddf2a380
@ -380,8 +380,8 @@ void CConsole::SuggestPanel(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CConsole::AutoComplete(void)
|
||||
{
|
||||
// Show ConVar/ConCommand suggestions when at least 2 characters have been entered.
|
||||
if (strlen(m_szInputBuf) > 1)
|
||||
// Show ConVar/ConCommand suggestions when something has been entered.
|
||||
if (m_szInputBuf[0])
|
||||
{
|
||||
if (m_bCanAutoComplete)
|
||||
{
|
||||
@ -620,7 +620,7 @@ void CConsole::BuildSuggestPanelRect(void)
|
||||
m_ivSuggestWindowPos = ImGui::GetItemRectMin();
|
||||
m_ivSuggestWindowPos.y += ImGui::GetItemRectSize().y;
|
||||
|
||||
float flWindowHeight = flSinglePadding + std::clamp(static_cast<float>(m_vSuggest.size()) * (flItemHeight), 37.0f, 127.5f);
|
||||
float flWindowHeight = (flSinglePadding + std::clamp(static_cast<float>(m_vSuggest.size()) * (flItemHeight), 37.0f, 127.5f));
|
||||
m_ivSuggestWindowSize = ImVec2(600, flWindowHeight);
|
||||
}
|
||||
|
||||
@ -826,7 +826,9 @@ int CConsole::TextEditCallback(ImGuiInputTextCallbackData* iData)
|
||||
}
|
||||
case ImGuiInputTextFlags_CallbackEdit:
|
||||
{
|
||||
for (size_t i = 0, n = strlen(iData->Buf); i < n; i++)
|
||||
if (size_t n = strlen(iData->Buf))
|
||||
{
|
||||
for (size_t i = 0; i < n; i++)
|
||||
{
|
||||
if (iData->Buf[i] != '~'
|
||||
&& iData->Buf[i] != '`'
|
||||
@ -842,6 +844,12 @@ int CConsole::TextEditCallback(ImGuiInputTextCallbackData* iData)
|
||||
|
||||
m_bCanAutoComplete = true;
|
||||
BuildSummary(iData->Buf);
|
||||
}
|
||||
else // Reset state and enable history scrolling when buffer is empty.
|
||||
{
|
||||
ResetAutoComplete();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user