Mercurial > vim
comparison src/drawline.c @ 34559:ef55fe2ac8be v9.1.0180
patch 9.1.0180: Cursor pos wrong when double-width chars are concealed
Commit: https://github.com/vim/vim/commit/010e1539d67442cc69a97bef6453efaf849d0db3
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu Mar 14 18:22:17 2024 +0100
patch 9.1.0180: Cursor pos wrong when double-width chars are concealed
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 14 Mar 2024 18:30:05 +0100 |
parents | 28dab9103dd5 |
children | fdd232ab72ea |
comparison
equal
deleted
inserted
replaced
34558:4fcffe60b441 | 34559:ef55fe2ac8be |
---|---|
3223 // 'tabstop' when there are concealed characters. | 3223 // 'tabstop' when there are concealed characters. |
3224 FIX_FOR_BOGUSCOLS; | 3224 FIX_FOR_BOGUSCOLS; |
3225 | 3225 |
3226 // Make sure, the highlighting for the tab char will be | 3226 // Make sure, the highlighting for the tab char will be |
3227 // correctly set further below (effectively reverts the | 3227 // correctly set further below (effectively reverts the |
3228 // FIX_FOR_BOGSUCOLS macro). | 3228 // FIX_FOR_BOGUSCOLS macro). |
3229 if (wlv.n_extra == tab_len + vc_saved && wp->w_p_list | 3229 if (wlv.n_extra == tab_len + vc_saved && wp->w_p_list |
3230 && wp->w_lcs_chars.tab1) | 3230 && wp->w_lcs_chars.tab1) |
3231 tab_len += vc_saved; | 3231 tab_len += vc_saved; |
3232 } | 3232 } |
3233 #endif | 3233 #endif |
3492 else if (wp->w_lcs_chars.conceal != NUL) | 3492 else if (wp->w_lcs_chars.conceal != NUL) |
3493 c = wp->w_lcs_chars.conceal; | 3493 c = wp->w_lcs_chars.conceal; |
3494 else | 3494 else |
3495 c = ' '; | 3495 c = ' '; |
3496 | 3496 |
3497 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) | |
3498 // When the first char to be concealed is double-width, | |
3499 // need to advance one more virtual column. | |
3500 wlv.n_extra++; | |
3501 | |
3502 mb_c = c; | |
3503 if (enc_utf8 && utf_char2len(c) > 1) | |
3504 { | |
3505 mb_utf8 = TRUE; | |
3506 u8cc[0] = 0; | |
3507 c = 0xc0; | |
3508 } | |
3509 else | |
3510 mb_utf8 = FALSE; // don't draw as UTF-8 | |
3511 | |
3497 prev_syntax_id = syntax_seqnr; | 3512 prev_syntax_id = syntax_seqnr; |
3498 | 3513 |
3499 if (wlv.n_extra > 0) | 3514 if (wlv.n_extra > 0) |
3500 wlv.vcol_off_co += wlv.n_extra; | 3515 wlv.vcol_off_co += wlv.n_extra; |
3501 wlv.vcol += wlv.n_extra; | 3516 wlv.vcol += wlv.n_extra; |
3520 else if (skip_cells == 0) | 3535 else if (skip_cells == 0) |
3521 { | 3536 { |
3522 is_concealing = TRUE; | 3537 is_concealing = TRUE; |
3523 skip_cells = 1; | 3538 skip_cells = 1; |
3524 } | 3539 } |
3525 mb_c = c; | |
3526 if (enc_utf8 && utf_char2len(c) > 1) | |
3527 { | |
3528 mb_utf8 = TRUE; | |
3529 u8cc[0] = 0; | |
3530 c = 0xc0; | |
3531 } | |
3532 else | |
3533 mb_utf8 = FALSE; // don't draw as UTF-8 | |
3534 } | 3540 } |
3535 else | 3541 else |
3536 { | 3542 { |
3537 prev_syntax_id = 0; | 3543 prev_syntax_id = 0; |
3538 is_concealing = FALSE; | 3544 is_concealing = FALSE; |
3988 } | 3994 } |
3989 } | 3995 } |
3990 #ifdef FEAT_CONCEAL | 3996 #ifdef FEAT_CONCEAL |
3991 else if (wp->w_p_cole > 0 && is_concealing) | 3997 else if (wp->w_p_cole > 0 && is_concealing) |
3992 { | 3998 { |
3999 int concealed_wide = has_mbyte && (*mb_char2cells)(mb_c) > 1; | |
4000 | |
3993 --skip_cells; | 4001 --skip_cells; |
3994 ++wlv.vcol_off_co; | 4002 ++wlv.vcol_off_co; |
4003 if (concealed_wide) | |
4004 { | |
4005 // When a double-width char is concealed, | |
4006 // need to advance one more virtual column. | |
4007 ++wlv.vcol; | |
4008 ++wlv.vcol_off_co; | |
4009 } | |
4010 | |
3995 if (wlv.n_extra > 0) | 4011 if (wlv.n_extra > 0) |
3996 wlv.vcol_off_co += wlv.n_extra; | 4012 wlv.vcol_off_co += wlv.n_extra; |
4013 | |
3997 if (wp->w_p_wrap) | 4014 if (wp->w_p_wrap) |
3998 { | 4015 { |
3999 // Special voodoo required if 'wrap' is on. | 4016 // Special voodoo required if 'wrap' is on. |
4000 // | 4017 // |
4001 // Advance the column indicator to force the line | 4018 // Advance the column indicator to force the line |
4024 } | 4041 } |
4025 wlv.n_extra = 0; | 4042 wlv.n_extra = 0; |
4026 n_attr = 0; | 4043 n_attr = 0; |
4027 } | 4044 } |
4028 | 4045 |
4029 | 4046 if (concealed_wide) |
4030 if (has_mbyte && (*mb_char2cells)(mb_c) > 1) | |
4031 { | 4047 { |
4032 // Need to fill two screen columns. | 4048 // Need to fill two screen columns. |
4033 # ifdef FEAT_RIGHTLEFT | 4049 # ifdef FEAT_RIGHTLEFT |
4034 if (wp->w_p_rl) | 4050 if (wp->w_p_rl) |
4035 { | 4051 { |