Fix scrollbar issue not respecting oy when window size taller than tty.

This commit is contained in:
Michael Grant
2026-03-09 16:28:06 +00:00
parent 28c04b21f6
commit e928e80a42

View File

@@ -1438,7 +1438,7 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
struct style *sb_style = &wp->scrollbar_style; struct style *sb_style = &wp->scrollbar_style;
u_int i, j, imin = 0, jmin = 0, imax, jmax; u_int i, j, imin = 0, jmin = 0, imax, jmax;
u_int sb_w = sb_style->width, sb_pad = sb_style->pad; u_int sb_w = sb_style->width, sb_pad = sb_style->pad;
int px, py, wx, wy, ox, oy, sx, sy; int px, py, wx, wy, ox, oy, sx, sy, sb_tty_y;
int xoff = wp->xoff; int xoff = wp->xoff;
int yoff = wp->yoff; int yoff = wp->yoff;
struct visible_ranges *r; struct visible_ranges *r;
@@ -1477,22 +1477,29 @@ screen_redraw_draw_scrollbar(struct screen_redraw_ctx *ctx,
return; return;
imax = sx - sb_x; imax = sx - sb_x;
} }
if (sb_y > oy + sy) /*
* sb_y is a window coordinate; convert to tty coordinate by
* subtracting the pan offset oy.
*/
sb_tty_y = sb_y - oy; /* scrollbar top in tty coordinates */
if (sb_tty_y > (int)sy)
/* Whole sb off screen. */ /* Whole sb off screen. */
return; return;
if (sb_y < 0) if (sb_tty_y < 0)
/* Part of sb on screen. */ /* Scrollbar starts above visible area; skip those rows. */
jmin = -sb_y; jmin = -sb_tty_y;
if ((int)sb_h < oy) if (sb_tty_y + (int)sb_h <= 0)
/* Whole sb above visible area. */
return; return;
jmax = sb_h; jmax = sb_h;
if ((int)jmax + sb_y > sy) if (sb_tty_y + (int)jmax > (int)sy)
/* Clip to height of tty. */ /* Clip to height of tty. */
jmax = sy - sb_y; jmax = sy - sb_tty_y;
for (j = jmin; j < jmax; j++) { for (j = jmin; j < jmax; j++) {
py = sb_y + j; /* tty y coordinate. */ wy = sb_y + j; /* window y coordinate. */
wy = sb_y + j + oy; /* window y coordinate. */ py = sb_tty_y + j; /* tty y coordinate. */
r = tty_check_overlay_range(tty, sb_x, wy, imax); r = tty_check_overlay_range(tty, sb_x, wy, imax);
r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r); r = screen_redraw_get_visible_ranges(wp, sb_x, wy, imax, r);
for (i = imin; i < imax; i++) { for (i = imin; i < imax; i++) {