From 264c104b097f7abf6e7dd7d791538830fccb8c5e Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 1 Mar 2024 09:52:53 +0100 Subject: [PATCH] ImGui: properly implement shift select The new method wraps around perfectly when the new selection positions overlap each other. This patch also fixes the shift selection drifting when lines are getting deleted. --- r5dev/thirdparty/imgui/misc/imgui_logger.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/r5dev/thirdparty/imgui/misc/imgui_logger.cpp b/r5dev/thirdparty/imgui/misc/imgui_logger.cpp index ffe6a8cd..312aa528 100644 --- a/r5dev/thirdparty/imgui/misc/imgui_logger.cpp +++ b/r5dev/thirdparty/imgui/misc/imgui_logger.cpp @@ -747,16 +747,14 @@ void CTextLogger::HandleMouseInputs(bool bHoveredScrollbar, bool bActiveScrollba { if (click) // Shift select range { - Coordinates newSelection = ScreenPosToCoordinates(ImGui::GetMousePos()); + const Coordinates newCursorPos = ScreenPosToCoordinates(ImGui::GetMousePos()); - if (newSelection > m_State.m_CursorPosition) - SetSelectionEnd(newSelection); - else - SetSelectionStart(newSelection); + // Set selection from old cursor pos to new cursor pos + m_SelectionMode = SelectionMode::Normal; + SetSelection(m_State.m_CursorPosition, newCursorPos, m_SelectionMode); m_InteractiveStart = m_State.m_SelectionStart; m_InteractiveEnd = m_State.m_SelectionEnd; - m_State.m_CursorPosition = newSelection; } } }