From b7d16b1f441cb7a98d7336fe0d1e2e08002dbd0f Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:47:50 +0100 Subject: [PATCH] ImGui: fix cursor scrolling bug * Fix bug where moving cursor all the way to the top + little bit, and then moving below will also scroll the text position below (cursor sticked to top rect). * Fix bug where cursor skipped a column when moving it past the right perimeter of the console. --- src/thirdparty/imgui/misc/imgui_logger.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thirdparty/imgui/misc/imgui_logger.cpp b/src/thirdparty/imgui/misc/imgui_logger.cpp index b9ed3cdb..415b0dba 100644 --- a/src/thirdparty/imgui/misc/imgui_logger.cpp +++ b/src/thirdparty/imgui/misc/imgui_logger.cpp @@ -1501,7 +1501,7 @@ void CTextLogger::EnsureCursorVisible() float width = ImGui::GetWindowWidth(); float height = ImGui::GetWindowHeight(); - float top = 1.0f + ImCeil(scrollY / m_CharAdvance.y); + float top = ImCeil(scrollY / m_CharAdvance.y); float bottom = ImCeil((scrollY + height) / m_CharAdvance.y); float left = ImCeil(scrollX / m_CharAdvance.x); @@ -1510,10 +1510,10 @@ void CTextLogger::EnsureCursorVisible() if (pos.m_nColumn < left) ImGui::SetScrollX(ImMax(0.0f, (pos.m_nColumn) * m_CharAdvance.x)); if (pos.m_nColumn > right - 3) - ImGui::SetScrollX(ImMax(0.0f, (pos.m_nColumn + 3) * m_CharAdvance.x - width)); + ImGui::SetScrollX(ImMax(0.0f, (pos.m_nColumn + 2) * m_CharAdvance.x - width)); if (pos.m_nLine < top) ImGui::SetScrollY(ImMax(0.0f, (pos.m_nLine) * m_CharAdvance.y)); - if (pos.m_nLine > bottom - 2) + if (pos.m_nLine > bottom - 3) ImGui::SetScrollY(ImMax(0.0f, (pos.m_nLine + 2) * m_CharAdvance.y - height)); }