Second try with static visual_ranges using calloc.

This commit is contained in:
Michael Grant
2026-01-29 14:34:18 +00:00
parent f67cf7d053
commit b46a96d454
2 changed files with 8 additions and 4 deletions

View File

@@ -1137,8 +1137,7 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
struct window_pane *wp;
struct window *w;
struct visible_range *ri;
static struct visible_range sr0 = { 0, 0 };
static struct visible_ranges sr = { &sr0, 1, 1 };
static struct visible_ranges sr = { NULL, 0, 0 };
int found_self, sb_w, sb_pos;
u_int lb, rb, tb, bb;
u_int i, s;
@@ -1148,8 +1147,13 @@ screen_redraw_get_visible_ranges(struct window_pane *base_wp, u_int px,
return (r);
} else {
/* Return static range as last resort. */
if (sr.ranges == NULL)
sr.ranges = xcalloc(1,
sizeof (struct visible_range));
sr.ranges[0].px = px;
sr.ranges[0].nx = width;
sr.size = 1;
sr.used = 1;
return (&sr);
}
}

View File

@@ -1849,13 +1849,13 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only,
ctx->scrolled = s->rlower - s->rupper + 1;
screen_write_initctx(ctx, &ttyctx, 1);
if (wp->yoff + wp->sy > wp->window->sy)
if (wp != NULL && wp->yoff + wp->sy > wp->window->sy)
ttyctx.orlower -= (wp->yoff + wp->sy - wp->window->sy);
ttyctx.num = ctx->scrolled;
ttyctx.bg = ctx->bg;
tty_write(tty_cmd_scrollup, &ttyctx);
if (ctx->wp != NULL)
if (wp != NULL)
ctx->wp->flags |= PANE_REDRAWSCROLLBAR;
}
ctx->scrolled = 0;