Implement Widget.render_delta_lines #4353
Draft
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.
The method
Widget.render_delta_lines
provides a mechanism for a widget to render itself and only issue strips that correspond to lines that actually changed.The code in this draft isn't as polished as it should be but provides a fairly decent proof of concept for this feature.
At the moment, the PR shows that all widgets have opted into this system and scrollbars have explicitly opted out.
In the future, this feature will probably only be used by some widgets (and not all) but I did this to test it better.
It is easy to see that this code already skips updating large chunks of apps.
To check this, you can do something as simple as adding a
print
inside the methodWidget.render_delta_lines
:Currently there is at least one bug with the implementation.
You can trigger this bug if you have an app with a single
Input
widget.Follow these steps to trigger the bug:
After the cursor blinks once, the top and bottom strips of the input will look weird, just like in this recording:
Screen.Recording.2024-03-28.at.15.29.52.mov
You can use this app to trigger the bug: