summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-07-16 10:30:56 +0000
committernicm <nicm@openbsd.org>2019-07-16 10:30:56 +0000
commit15e17edae7dec9ec139776c2c12ec842dd62d2d4 (patch)
tree0d76e6c08a6e50324fc95810cc999668fa9697df
parentso the output changed slightly, again (diff)
downloadwireguard-openbsd-15e17edae7dec9ec139776c2c12ec842dd62d2d4.tar.xz
wireguard-openbsd-15e17edae7dec9ec139776c2c12ec842dd62d2d4.zip
Fix grid clear code to correctly clear with the default background
colour rather than ending up with the used count higher than the total size, GitHub issue 1829.
-rw-r--r--usr.bin/tmux/grid-view.c3
-rw-r--r--usr.bin/tmux/grid.c30
2 files changed, 20 insertions, 13 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c
index e28b6836aa6..686cf3c7252 100644
--- a/usr.bin/tmux/grid-view.c
+++ b/usr.bin/tmux/grid-view.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid-view.c,v 1.31 2018/07/04 09:44:07 nicm Exp $ */
+/* $OpenBSD: grid-view.c,v 1.32 2019/07/16 10:30:56 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -214,7 +214,6 @@ grid_view_delete_cells(struct grid *gd, u_int px, u_int py, u_int nx, u_int bg)
sx = grid_view_x(gd, gd->sx);
grid_move_cells(gd, px, px + nx, py, sx - px - nx, bg);
- grid_clear(gd, sx - nx, py, px + nx - (sx - nx), 1, bg);
}
/* Convert cells into a string. */
diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c
index 878e4b22a43..ee5064ef011 100644
--- a/usr.bin/tmux/grid.c
+++ b/usr.bin/tmux/grid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grid.c,v 1.97 2019/07/06 20:37:29 nicm Exp $ */
+/* $OpenBSD: grid.c,v 1.98 2019/07/16 10:30:56 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -547,7 +547,7 @@ void
grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg)
{
struct grid_line *gl;
- u_int xx, yy;
+ u_int xx, yy, ox, sx;
if (nx == 0 || ny == 0)
return;
@@ -564,16 +564,20 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, u_int bg)
for (yy = py; yy < py + ny; yy++) {
gl = &gd->linedata[yy];
- if (px + nx >= gd->sx && px < gl->cellused)
- gl->cellused = px;
- if (px > gl->cellsize && COLOUR_DEFAULT(bg))
- continue;
- if (px + nx >= gl->cellsize && COLOUR_DEFAULT(bg)) {
- gl->cellsize = px;
- continue;
+
+ sx = gd->sx;
+ if (sx > gl->cellsize)
+ sx = gl->cellsize;
+ ox = nx;
+ if (COLOUR_DEFAULT(bg)) {
+ if (px > sx)
+ continue;
+ if (px + nx > sx)
+ ox = sx - px;
}
- grid_expand_line(gd, yy, px + nx, 8); /* default bg first */
- for (xx = px; xx < px + nx; xx++)
+
+ grid_expand_line(gd, yy, px + ox, 8); /* default bg first */
+ for (xx = px; xx < px + ox; xx++)
grid_clear_cell(gd, xx, yy, bg);
}
}
@@ -1216,6 +1220,10 @@ grid_reflow(struct grid *gd, u_int sx)
struct grid_cell gc;
u_int yy, width, i, at, first;
+ /* Do not reflow to the same size. */
+ if (sx == gd->sx)
+ return;
+
/*
* Create a destination grid. This is just used as a container for the
* line data and may not be fully valid.