Mercurial > vim
diff src/drawline.c @ 29583:32aee589fc9a v9.0.0132
patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Commit: https://github.com/vim/vim/commit/09ff4b54fb86a64390ba9c609853c6410ea6197c
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Aug 1 16:51:02 2022 +0100
patch 9.0.0132: multi-byte characters in virtual text not handled correctly
Problem: Multi-byte characters in virtual text not handled correctly.
Solution: Count screen cells instead of bytes.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 01 Aug 2022 18:00:05 +0200 |
parents | f7a64755dbe9 |
children | f2d7f20d83c3 |
line wrap: on
line diff
--- a/src/drawline.c +++ b/src/drawline.c @@ -279,7 +279,7 @@ win_line( int screen_row; // row on the screen, incl w_winrow char_u extra[21]; // "%ld " and 'fdc' must fit in here - int n_extra = 0; // number of extra chars + int n_extra = 0; // number of extra bytes char_u *p_extra = NULL; // string of extra chars, plus NUL char_u *p_extra_free = NULL; // p_extra needs to be freed int c_extra = NUL; // extra chars, all the same @@ -1560,7 +1560,7 @@ win_line( c_final = NUL; n_extra = (int)STRLEN(p); extra_attr = used_attr; - n_attr = n_extra; + n_attr = mb_charlen(p); text_prop_attr = 0; if (*ptr == NUL) // don't combine char attr after EOL @@ -1573,9 +1573,8 @@ win_line( char_u *l; // Right-align: fill with spaces - // TODO: count screen columns if (right) - added -= n_extra; + added -= vim_strsize(p_extra); if (added < 0 || (below && col == 0)) added = 0; l = alloc(n_extra + added + 1);