diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-18 21:36:56 +0100 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-01-18 21:36:56 +0100 |
| commit | 3deb2b3970cb344d0c615e9d41a5fe7f3baf1417 (patch) | |
| tree | 144aa3f120d4276aa5d15496c8927ed050350af7 /src/string-utils.c | |
| parent | b5dac044ddda2d2057d1d785d5827c1b890c90b6 (diff) | |
fixed auto-completion of Unicode file names
* teco_string_diff() could return a number of bytes in the middle of
an Unicode sequence. It now also requires Unicode strings.
* Added a missing Unicode-validity check when replacing command lines (`{` and `}`).
teco_cmdline_insert() should really be refactored, though (FIXME).
* Added test case
Diffstat (limited to 'src/string-utils.c')
| -rw-r--r-- | src/string-utils.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/string-utils.c b/src/string-utils.c index e9dd148..d98b6b0 100644 --- a/src/string-utils.c +++ b/src/string-utils.c @@ -87,8 +87,10 @@ teco_string_get_coord(const gchar *str, gsize off, guint *pos, guint *line, guin } /** - * Get the length of the prefix common to two strings. - * Works with UTF-8 and single-byte encodings. + * Get the length of the prefix common to two UTF-8 strings. + * + * The UTF-8 strings must be validated, which should be the case + * for help labels and short Q-Register names. * * @param a Left string. * @param b Right string. @@ -103,8 +105,8 @@ teco_string_diff(teco_string_t a, const gchar *b, gsize b_len) gsize len = 0; while (len < a.len && len < b_len && - a.data[len] == b[len]) - len++; + g_utf8_get_char(a.data+len) == g_utf8_get_char(b+len)) + len = g_utf8_next_char(b+len) - b; return len; } |
