-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Rewrite the insert_before method on Terminal to fix a bug and remove the height cap #596
fix: Rewrite the insert_before method on Terminal to fix a bug and remove the height cap #596
Conversation
Codecov Report
@@ Coverage Diff @@
## main #596 +/- ##
==========================================
+ Coverage 89.56% 90.47% +0.91%
==========================================
Files 41 41
Lines 11571 11890 +319
==========================================
+ Hits 10363 10758 +395
+ Misses 1208 1132 -76
|
Fixes issue with inserting content with height>viewport_area.height and adds the ability to insert content of height>terminal_height
I think it's probably worth adding the clear ops to the TestBackend to help with this change. There are three main reasons I like to add test coverage to existing code before changing it:
These reasons each make changes easier to review as otherwise a reviewer has to determine whether the code did the right thing originally by fully understanding the code, and whether it now still does the right thing by understanding the new code. Tests like this also help capture if there are breaking changes that other users need to know about. Here the code is not too complex, but I don't fully understand it. It currently does a particular thing and I'm not sure I know why it does that enough to understand whether the change is right. My approach generally would be to write characterization tests that fully cover the problem code, commit them, then make the changes and see which tests break. How about adding the missing TestBackend implementations for clear that would show how this works and then adding the tests for this? Do you think this sound reasonable? |
That's reasonable yes, I'll work on adding that functionality to the |
Also adds and tests clear_region and append_lines methods to the TestBackend
I've added the functionality we discussed above, the |
Slightly related, maybe we should set a threshold in codecov.yml? |
I'd be happy to add one if you think it makes sense in this PR, do you have an acceptable value in mind? Alternatively, if this requires further discussion maybe it would be better suited to its own Issue/PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overarching context of my review is that I'm not as familiar with the workings of this code as you are, so I'm looking for help with the changes and tests to make it more clear that the changes are correct. They might mean that the feedback is a bit pedantic, and for that effect I apologize in advance. But I'd encourage you to think about this change with the perspective of "how would I explain these changes to someone that is reading it for the first time?" (because that's not far from the truth)
Another PR would be right for this #612 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes - I understand TestBackend::append_lines()
much better now. Lots of detailed feedback again that I hope will make this better, and I think there's a couple of possible bugs that I'm not sure of.
I've merged this - thanks for sticking with it to get it over the line. It should be available in the alpha release this Saturday. |
This PR fixes some issues encountered in #584 by way of rewriting the
insert_before
method.Ultimately it does two things:
height
parameter of a call toinsert_before
being greater thanself.viewport_area.height
- This bug would cause an extra newline to be inserted leaving a gap in the output.height
cap by rendering output in chunks. ifheight
is too large to fit on the screen (with the viewport) then chunks are rendered as the screen is scrolled.A Note About Test Coverage
There are currently no tests for theinsert_before
method; I've attempted to test this change with theTestBackend
but unfortunately due to it not supporting clearClearType::AfterCursor
this would prove difficult and I think the noise of adding this functionality wouldn't be worth adding to this PR. As it's a very minimal hit I wondered if it's acceptable?