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.
What it does
Fixes autoscrolling functionality in debug console. How this should work, is if the console is scrolled to the bottom, then when new content is output, it should be shown automatically, but if the user scrolls up, the view should stay put.
How to test
This functionality can be tested with any debuggable project. For example I used the cpp-debug-workspace, which after installing cdt-gdb-vscode, can be debugged following the instructions in the README.md file. To test, place a breakpoint within the main loop i.e.
a.cpp:35
. Allow the debugger to continue a few times. Each time it does, any new output to the debug console should be shown automatically. Then, scroll up a few lines and continue a few more times. Now the view should remain fixed.Explanation
Here's how it worked previously:
When
ConsoleContentWidget.model.onChanged()
is fired, this triggers 3 notable events:ConsoleWidget.revealLastOutputIfNeeded
,TreeWidget.updateScrollToRow
, andTreeWidget.updateRows
usually in that order.revealLastOutputIfNeeded
uses the selection service to focus the newly added node. Next,updateScrollToRow
attempts to find the row corresponding the the focused node, and fails to find it and thus doesn't scroll. Finally, after that happensupdateRows
creates the corresponding row.Furthermore, the logic to determine when the console should be scrolling or not uses the
onScrollUp
, andonScrollYReachEnd
methods, which don't appear fire for tree widgets (they work for other widgets). I believe this is because it's not the root widget container that is scrolling, but one of it's child elements, but wasn't able to figure this out.Follow-ups
Breaking changes
Attribution
Review checklist
Reminder for reviewers