aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-15 06:56:45 +0800
committerGitHub <noreply@github.com>2024-03-15 06:56:45 +0800
commit60491466f951f93d8d9010645e1dac367f3ea979 (patch)
treec798827c6744f1538061932f6d2d9e5f04f7520c /src
parentca7dd33fa783181d62b0573082d2e691fcfc29d2 (diff)
downloadrneovim-60491466f951f93d8d9010645e1dac367f3ea979.tar.gz
rneovim-60491466f951f93d8d9010645e1dac367f3ea979.tar.bz2
rneovim-60491466f951f93d8d9010645e1dac367f3ea979.zip
vim-patch:9.1.0180: Cursor pos wrong when double-width chars are concealed (#27862)
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: vim/vim#14197 https://github.com/vim/vim/commit/010e1539d67442cc69a97bef6453efaf849d0db3
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawline.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 2f541a8a21..dfe3dbca50 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -2403,6 +2403,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
} else {
mb_schar = schar_from_ascii(' ');
}
+
+ if (utf_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 = schar_get_first_codepoint(mb_schar);
prev_syntax_id = syntax_seqnr;
@@ -2739,11 +2746,21 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
wlv.off++;
wlv.col++;
} else if (wp->w_p_cole > 0 && is_concealing) {
+ bool concealed_wide = utf_char2cells(mb_c) > 1;
+
wlv.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 (is_wrapped) {
// Special voodoo required if 'wrap' is on.
//
@@ -2764,7 +2781,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
wlv.n_attr = 0;
}
- if (utf_char2cells(mb_c) > 1) {
+ if (concealed_wide) {
// Need to fill two screen columns.
wlv.boguscols++;
wlv.col++;