comparison 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
comparison
equal deleted inserted replaced
29582:902abc03f8ee 29583:32aee589fc9a
277 char_u *ptr; // current position in "line" 277 char_u *ptr; // current position in "line"
278 int row; // row in the window, excl w_winrow 278 int row; // row in the window, excl w_winrow
279 int screen_row; // row on the screen, incl w_winrow 279 int screen_row; // row on the screen, incl w_winrow
280 280
281 char_u extra[21]; // "%ld " and 'fdc' must fit in here 281 char_u extra[21]; // "%ld " and 'fdc' must fit in here
282 int n_extra = 0; // number of extra chars 282 int n_extra = 0; // number of extra bytes
283 char_u *p_extra = NULL; // string of extra chars, plus NUL 283 char_u *p_extra = NULL; // string of extra chars, plus NUL
284 char_u *p_extra_free = NULL; // p_extra needs to be freed 284 char_u *p_extra_free = NULL; // p_extra needs to be freed
285 int c_extra = NUL; // extra chars, all the same 285 int c_extra = NUL; // extra chars, all the same
286 int c_final = NUL; // final char, mandatory if set 286 int c_final = NUL; // final char, mandatory if set
287 int extra_attr = 0; // attributes when n_extra != 0 287 int extra_attr = 0; // attributes when n_extra != 0
1558 p_extra = p; 1558 p_extra = p;
1559 c_extra = NUL; 1559 c_extra = NUL;
1560 c_final = NUL; 1560 c_final = NUL;
1561 n_extra = (int)STRLEN(p); 1561 n_extra = (int)STRLEN(p);
1562 extra_attr = used_attr; 1562 extra_attr = used_attr;
1563 n_attr = n_extra; 1563 n_attr = mb_charlen(p);
1564 text_prop_attr = 0; 1564 text_prop_attr = 0;
1565 if (*ptr == NUL) 1565 if (*ptr == NUL)
1566 // don't combine char attr after EOL 1566 // don't combine char attr after EOL
1567 text_prop_combine = FALSE; 1567 text_prop_combine = FALSE;
1568 1568
1571 { 1571 {
1572 int added = wp->w_width - col; 1572 int added = wp->w_width - col;
1573 char_u *l; 1573 char_u *l;
1574 1574
1575 // Right-align: fill with spaces 1575 // Right-align: fill with spaces
1576 // TODO: count screen columns
1577 if (right) 1576 if (right)
1578 added -= n_extra; 1577 added -= vim_strsize(p_extra);
1579 if (added < 0 || (below && col == 0)) 1578 if (added < 0 || (below && col == 0))
1580 added = 0; 1579 added = 0;
1581 l = alloc(n_extra + added + 1); 1580 l = alloc(n_extra + added + 1);
1582 if (l != NULL) 1581 if (l != NULL)
1583 { 1582 {