From 794a48fd26f841b5e0e6b674f433e6c1ba970453 Mon Sep 17 00:00:00 2001 From: paxcut Date: Tue, 7 Jan 2025 10:08:25 -0700 Subject: [PATCH] fix: find jumps to wrong location. After successfully finding matches and setting the cursor to them, the screen would jump to the original window location upon closing the window. The error was caused by the wrong assumption that the scroll location should be restored when window is closed. Instead, the right ammount of scrolling needs to be calculated to account for the window no longer covering part of the text editor. Unused variable was discarded. Another unrelated error is that the history of search names cannot be accessed which will be addressed at a later PR. --- lib/third_party/imgui/ColorTextEditor/include/TextEditor.h | 1 - lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/third_party/imgui/ColorTextEditor/include/TextEditor.h b/lib/third_party/imgui/ColorTextEditor/include/TextEditor.h index f9cdd08674639..e4521ce702f00 100644 --- a/lib/third_party/imgui/ColorTextEditor/include/TextEditor.h +++ b/lib/third_party/imgui/ColorTextEditor/include/TextEditor.h @@ -629,7 +629,6 @@ class TextEditor uint64_t mStartTime = 0; std::vector mDefines; TextEditor *mSourceCodeEditor = nullptr; - float mSavedScrollY = 0; float mShiftedScrollY = 0; float mScrollY = 0; float mScrollYIncrement = 0.0F; diff --git a/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp b/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp index c86d435baab2f..5ba2d1e5a27a6 100644 --- a/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp +++ b/lib/third_party/imgui/ColorTextEditor/source/TextEditor.cpp @@ -1179,8 +1179,6 @@ void TextEditor::RenderText(const char *aTitle, const ImVec2 &lineNumbersStartPo if (mTopMarginChanged) { mTopMarginChanged = false; - if (mTopMargin == 0) - mSavedScrollY = ImGui::GetScrollY(); auto window = ImGui::GetCurrentWindow(); auto maxScroll = window->ScrollMax.y; if (maxScroll > 0) { @@ -1196,10 +1194,8 @@ void TextEditor::RenderText(const char *aTitle, const ImVec2 &lineNumbersStartPo if (mNewTopMargin > mTopMargin) mShiftedScrollY = oldScrollY + pixelCount; - else if (mNewTopMargin > 0) - mShiftedScrollY = oldScrollY - pixelCount; else - mShiftedScrollY = mSavedScrollY; + mShiftedScrollY = oldScrollY - pixelCount; ImGui::SetScrollY(mShiftedScrollY); mTopMargin = mNewTopMargin; }