Skip to content

Commit

Permalink
fix(terminal): Terminal::insert_before would crash when called while …
Browse files Browse the repository at this point in the history
…the viewport filled the screen (#1329)

Reimplement Terminal::insert_before. The previous implementation would
insert the new lines in chunks into the area between the top of the
screen and the top of the (new) viewport. If the viewport filled the
screen, there would be no area in which to insert lines, and the
function would crash.

The new implementation uses as much of the screen as it needs to, all
the way up to using the whole screen.

This commit:
- adds a scrollback buffer to the `TestBackend` so that tests can
inspect and assert the state of the scrollback buffer in addition to the
screen
- adds functions to `TestBackend` to assert the state of the scrollback
- adds and updates `TestBackend` tests to test the behavior of the
scrollback and the new asserting functions
- reimplements `Terminal::insert_before`, including adding two new
helper functions `Terminal::draw_lines` and `Terminal::scroll_up`.
- updates the documentation for `Terminal::insert_before` to clarify
some of the edge cases
- updates terminal tests to assert the state of the scrollback buffer
- adds a new test for the condition that causes the bug
- adds a conversion constructor `Cell::from(char)`

Fixes: #999
  • Loading branch information
nfachan committed Aug 23, 2024
1 parent 3631b34 commit aed60b9
Show file tree
Hide file tree
Showing 4 changed files with 473 additions and 65 deletions.
Loading

0 comments on commit aed60b9

Please sign in to comment.