From bc51449ff1a8f2083c5b06998f1b448f184357ea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Sep 2023 16:03:57 +1000 Subject: [PATCH] Fix cursor motion across characters with an unknown column width BLI_str_utf8_char_width returns -1 for character without a known width. This caused the right cursor motion to skip these characters. While editable text should not contain control characters, cursor motion should behave properly in cases when they do. --- source/blender/blenlib/intern/string_cursor_utf8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 139ba080288..edf36dc77c5 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -121,7 +121,7 @@ bool BLI_str_cursor_step_next_utf8(const char *str, size_t str_maxlen, int *pos) const char *str_next = str_pos; do { str_next = BLI_str_find_next_char_utf8(str_next, str_end); - } while (str_next < str_end && str_next[0] != 0 && BLI_str_utf8_char_width(str_next) < 1); + } while (str_next < str_end && str_next[0] != 0 && BLI_str_utf8_char_width(str_next) == 0); (*pos) += (str_next - str_pos); if ((*pos) > (int)str_maxlen) { (*pos) = (int)str_maxlen;