Handle multiline cursor movement in zsh when clicking

This commit is contained in:
Kovid Goyal 2021-08-15 20:48:29 +05:30
parent 2715947830
commit fab7cfb113
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -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;
}