From 6d68d2a21f194f228045a7931f7b21f2530d1c10 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 10 Jun 2021 07:22:37 +0000 Subject: [PATCH] back-to-indentation fixes, from Anindya Mukherjee. --- usr.bin/tmux/grid-reader.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/usr.bin/tmux/grid-reader.c b/usr.bin/tmux/grid-reader.c index 4d36bfbb0bb..caecceb40db 100644 --- a/usr.bin/tmux/grid-reader.c +++ b/usr.bin/tmux/grid-reader.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid-reader.c,v 1.4 2021/04/05 08:43:48 nicm Exp $ */ +/* $OpenBSD: grid-reader.c,v 1.5 2021/06/10 07:22:37 nicm Exp $ */ /* * Copyright (c) 2020 Anindya Mukherjee @@ -371,19 +371,26 @@ void grid_reader_cursor_back_to_indentation(struct grid_reader *gr) { struct grid_cell gc; - u_int px, py, xx, yy; + u_int px, py, xx, yy, oldx, oldy; yy = gr->gd->hsize + gr->gd->sy - 1; + oldx = gr->cx; + oldy = gr->cy; grid_reader_cursor_start_of_line(gr, 1); for (py = gr->cy; py <= yy; py++) { xx = grid_line_length(gr->gd, py); for (px = 0; px < xx; px++) { grid_get_cell(gr->gd, px, py, &gc); - if (gc.data.size != 1 || *gc.data.data != ' ') - break; + if (gc.data.size != 1 || *gc.data.data != ' ') { + gr->cx = px; + gr->cy = py; + return; + } } if (~grid_get_line(gr->gd, py)->flags & GRID_LINE_WRAPPED) break; } + gr->cx = oldx; + gr->cy = oldy; } -- 2.20.1