From a552610fdb721980bc455c7dc8636bc13d8f698b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 5 Dec 2020 11:59:56 +0100 Subject: [PATCH] render: search: handle multi-column characters --- render.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/render.c b/render.c index 565e8878..2a8a50dd 100644 --- a/render.c +++ b/render.c @@ -2117,7 +2117,8 @@ render_search_box(struct terminal *term) { assert(term->window->search_sub_surface != NULL); - const size_t wanted_visible_chars = max(20, term->search.len); + const size_t wanted_visible_chars = max( + 20, wcsnlen(term->search.buf, term->search.len)); assert(term->scale >= 1); const int scale = term->scale; @@ -2199,7 +2200,7 @@ render_search_box(struct terminal *term) pixman_image_unref(src); } - x += term->cell_width; + x += max(1, wcwidth(term->search.buf[i])) * term->cell_width; } if (term->search.cursor >= term->search.len)