diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index de4780a0b3f..a2aa1baa05c 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -120,6 +120,8 @@ void CChat::Reset() m_LastChatSend = 0; m_CurrentLine = 0; m_IsInputCensored = false; + m_EditingNewLine = true; + mem_zero(m_aCurrentInputText, sizeof(m_aCurrentInputText)); DisableMode(); for(int64_t &LastSoundPlayed : m_aLastSoundPlayed) @@ -426,6 +428,12 @@ bool CChat::OnInput(const IInput::CEvent &Event) if(Event.m_Flags & IInput::FLAG_PRESS && Event.m_Key == KEY_UP) { + if(m_EditingNewLine) + { + str_copy(m_aCurrentInputText, m_Input.GetString()); + m_EditingNewLine = false; + } + if(m_pHistoryEntry) { CHistoryEntry *pTest = m_History.Prev(m_pHistoryEntry); @@ -445,9 +453,14 @@ bool CChat::OnInput(const IInput::CEvent &Event) m_pHistoryEntry = m_History.Next(m_pHistoryEntry); if(m_pHistoryEntry) + { m_Input.Set(m_pHistoryEntry->m_aText); - else - m_Input.Clear(); + } + else if(!m_EditingNewLine) + { + m_Input.Set(m_aCurrentInputText); + m_EditingNewLine = true; + } } return true; diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 52f1082c05d..55d95b5de32 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -123,6 +123,8 @@ class CChat : public CComponent int64_t m_LastChatSend; int64_t m_aLastSoundPlayed[CHAT_NUM]; bool m_IsInputCensored; + char m_aCurrentInputText[MAX_LINE_LENGTH]; + bool m_EditingNewLine; static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData);