From 4031e15fc8894cae9165e672c40b669a4f434f45 Mon Sep 17 00:00:00 2001 From: Learath Date: Thu, 22 Feb 2018 20:46:02 +0100 Subject: [PATCH] Remove extra conditional Stricter scope on temporary var. --- src/game/client/components/chat.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 48c68957b..39346c2b2 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -162,10 +162,10 @@ bool CChat::OnInput(IInput::CEvent Event) else if(Input()->KeyPress(KEY_RIGHT) || Input()->KeyPress(KEY_DELETE)) SearchDirection = 1; - int OldOffset = m_Input.GetCursorOffset(); - if(SearchDirection != 0) { + int OldOffset = m_Input.GetCursorOffset(); + int FoundAt = SearchDirection > 0 ? m_Input.GetLength() - 1 : 0; for(int i = m_Input.GetCursorOffset() + SearchDirection; SearchDirection > 0 ? i < m_Input.GetLength() - 1 : i > 0; i += SearchDirection) { @@ -181,6 +181,7 @@ bool CChat::OnInput(IInput::CEvent Event) break; } } + if(Input()->KeyPress(KEY_BACKSPACE)) { if(m_Input.GetCursorOffset() != 0) @@ -207,9 +208,10 @@ bool CChat::OnInput(IInput::CEvent Event) str_append(aText, m_Input.GetString() + FoundAt, sizeof(aText)); m_Input.Set(aText); + FoundAt = OldOffset; } } - m_Input.SetCursorOffset(Input()->KeyPress(KEY_DELETE) ? OldOffset : FoundAt); + m_Input.SetCursorOffset(FoundAt); } }