From fab7cfb1136c0a49e93f47e1b2dba76447723a5e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 15 Aug 2021 20:48:29 +0530 Subject: [PATCH] Handle multiline cursor movement in zsh when clicking --- kitty/screen.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kitty/screen.c b/kitty/screen.c index ffc7afc5d..048b6cc77 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1362,12 +1362,16 @@ screen_fake_move_cursor_to_position(Screen *self, index_type x, index_type y) { SelectionBoundary *start, *end; int key; if (a.y < b.y || (a.y == b.y && a.x < b.x)) { start = &a; end = &b; key = GLFW_FKEY_LEFT; } else { start = &b; end = &a; key = GLFW_FKEY_RIGHT; } - unsigned count = 0; + unsigned int count = 0; for (unsigned y = start->y, x = start->x; y <= end->y; y++) { unsigned x_limit = y == end->y ? end->x : self->columns; while (x < x_limit) { - unsigned w = MAX(1u, linebuf_char_width_at(self->linebuf, x, y)); + unsigned int w = linebuf_char_width_at(self->linebuf, x, y); + if (w == 0) { + count += 1; + break; + } x += w; count += w; }