diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-03-14 18:22:17 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-03-14 18:22:17 +0100 |
commit | 010e1539d67442cc69a97bef6453efaf849d0db3 (patch) | |
tree | 3e5566577624a5a4b3c9ba437b8b29944bb3980c /src/drawline.c | |
parent | 9352c282928f6cb25060249c157a28803c6efa9d (diff) |
patch 9.1.0180: Cursor pos wrong when double-width chars are concealedv9.1.0180
Problem: Cursor pos wrong when double-width chars are concealed.
Solution: Advance one more virtual column for a double-width char.
Run some tests with both 'wrap' and 'nowrap' (zeertzjq).
closes: #14197
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/drawline.c')
-rw-r--r-- | src/drawline.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/drawline.c b/src/drawline.c index 112dc6466a..9368095485 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -3225,7 +3225,7 @@ win_line( // Make sure, the highlighting for the tab char will be // correctly set further below (effectively reverts the - // FIX_FOR_BOGSUCOLS macro). + // FIX_FOR_BOGUSCOLS macro). if (wlv.n_extra == tab_len + vc_saved && wp->w_p_list && wp->w_lcs_chars.tab1) tab_len += vc_saved; @@ -3494,6 +3494,21 @@ win_line( else c = ' '; + if (has_mbyte && (*mb_char2cells)(mb_c) > 1) + // When the first char to be concealed is double-width, + // need to advance one more virtual column. + wlv.n_extra++; + + mb_c = c; + if (enc_utf8 && utf_char2len(c) > 1) + { + mb_utf8 = TRUE; + u8cc[0] = 0; + c = 0xc0; + } + else + mb_utf8 = FALSE; // don't draw as UTF-8 + prev_syntax_id = syntax_seqnr; if (wlv.n_extra > 0) @@ -3522,15 +3537,6 @@ win_line( is_concealing = TRUE; skip_cells = 1; } - mb_c = c; - if (enc_utf8 && utf_char2len(c) > 1) - { - mb_utf8 = TRUE; - u8cc[0] = 0; - c = 0xc0; - } - else - mb_utf8 = FALSE; // don't draw as UTF-8 } else { @@ -3990,10 +3996,21 @@ win_line( #ifdef FEAT_CONCEAL else if (wp->w_p_cole > 0 && is_concealing) { + int concealed_wide = has_mbyte && (*mb_char2cells)(mb_c) > 1; + --skip_cells; ++wlv.vcol_off_co; + if (concealed_wide) + { + // When a double-width char is concealed, + // need to advance one more virtual column. + ++wlv.vcol; + ++wlv.vcol_off_co; + } + if (wlv.n_extra > 0) wlv.vcol_off_co += wlv.n_extra; + if (wp->w_p_wrap) { // Special voodoo required if 'wrap' is on. @@ -4026,8 +4043,7 @@ win_line( n_attr = 0; } - - if (has_mbyte && (*mb_char2cells)(mb_c) > 1) + if (concealed_wide) { // Need to fill two screen columns. # ifdef FEAT_RIGHTLEFT |