fix(tui): avoid invalidating regions with uninitialized grid

Problem:  Invalidated regions are flushed during startup while grid is
          still uninitialized. Resulting in blanking the grid to black,
          perceived as flickering.
Solution: Avoid flushing invalidated regions while the grid is
          uninitialized.
This commit is contained in:
Luuk van Baal 2024-05-09 18:12:44 +02:00
parent 064f3e42e8
commit b75dbe8df3
1 changed files with 8 additions and 0 deletions

View File

@ -108,6 +108,7 @@ struct TUIData {
bool set_cursor_color_as_str;
bool cursor_color_changed;
bool is_starting;
bool got_line;
FILE *screenshot;
cursorentry_T cursor_shapes[SHAPE_IDX_COUNT];
HlAttrs clear_attrs;
@ -1436,6 +1437,12 @@ void tui_flush(TUIData *tui)
}
while (kv_size(tui->invalid_regions)) {
// We don't want to invalidate regions when the entire grid is still invalid.
// Doing so will result in unnecessarily blanking the grid which results in flickering.
if (!tui->got_line) {
kv_size(tui->invalid_regions) = 0;
break;
}
Rect r = kv_pop(tui->invalid_regions);
assert(r.bot <= grid->height && r.right <= grid->width);
@ -1616,6 +1623,7 @@ void tui_raw_line(TUIData *tui, Integer g, Integer linerow, Integer startcol, In
Integer clearcol, Integer clearattr, LineFlags flags, const schar_T *chunk,
const sattr_T *attrs)
{
tui->got_line = true;
UGrid *grid = &tui->grid;
for (Integer c = startcol; c < endcol; c++) {
grid->cells[linerow][c].data = chunk[c - startcol];