From 5ebab9dea94c1fd06293e71ea3b904bc9902ad1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 5 Oct 2020 18:29:24 +0200 Subject: [PATCH] sixel: verify scrollback consistency: new verify function Verifies sixels have been scrolled out correctly --- sixel.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sixel.c b/sixel.c index e55b52b0..6c378546 100644 --- a/sixel.c +++ b/sixel.c @@ -179,6 +179,31 @@ verify_no_wraparound_crossover(const struct terminal *term) #endif } +/* + * Verify there aren't any sixels that cross the scrollback end. This + * invariant means a sixel's rebased row numbers are strictly + * increasing. + */ +static void +verify_scrollback_consistency(const struct terminal *term) +{ +#if defined(_DEBUG) + tll_foreach(term->grid->sixel_images, it) { + const struct sixel *six = &it->item; + + int last_row = -1; + for (int i = 0; i < six->rows; i++) { + int row_no = rebase_row(term, six->pos.row + i); + + if (last_row != -1) + assert(last_row < row_no); + + last_row = row_no; + } + } +#endif +} + /* * Verifies no sixel overlap with any other sixels. */ @@ -223,6 +248,7 @@ static void verify_sixels(const struct terminal *term) { verify_no_wraparound_crossover(term); + verify_scrollback_consistency(term); verify_no_overlap(term); verify_list_order(term); }