Fix ConsoleWidget ReplWidget.write() always scrolling to bottom (scrollToBottom not working)#3140
Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom Oct 13, 2024
jack-mil:repl-auto-scroll
Merged
Fix ConsoleWidget ReplWidget.write() always scrolling to bottom (scrollToBottom not working)#3140j9ac9k merged 1 commit intopyqtgraph:masterfrom jack-mil:repl-auto-scroll
scrollToBottom not working)#3140j9ac9k merged 1 commit intopyqtgraph:masterfrom
jack-mil:repl-auto-scroll
Conversation
Member
|
Thank you for the PR @jack-mil this LGTM, merging! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Despite having
scrollToBottom='auto'inReplWidgetset to auto, the TextEdit scroll area would always scroll to the bottom, to most recently inserted text.Desired behavior: have the scroll view stay in place if not at the bottom.
I messed around with lots of things trying to get it to work as expected. I found that moving the text cursor to the end also scrolled the view. There is no mention of this behavior in the QT docs. It does not seem to matter whether
QTextEdit.moveCursor()is used, or first getting a reference, moving the cursor, and setting again usingQTextEdit.setCursor()(as was being used here before. This issue was made especially hard to diagnose because the cursor is not visible.The
QTextEdit.insertPlainText()method does work as expected, and moves the cursor to the end of the inserted text. This does not scroll the view (unlikeappend()).I eventually settled on just removing the line that moves the cursor to the end near the beginning of ReplWidget.write(). This fixed the issue, and I only had to change the one other place the QTextEdit has text added to use insert instead of set in order to update the cursor position to the right place upon initialization (in
ConsoleWidget.__init__()).The other changes are just pre-commit auto formatting.