diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-01 12:06:31 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-01 12:06:31 +0100 |
commit | 782c6744b49b30d9460ed00d4773666e42e07163 (patch) | |
tree | bf703612f9646593492f7dbc275896791095d39e /src/edit.c | |
parent | 96e08e028cbcda23dccf83de6b71b3c6bf1f9d4a (diff) | |
download | vim-git-782c6744b49b30d9460ed00d4773666e42e07163.tar.gz |
patch 8.2.4660: cursorcolumn is sometimes not correctv8.2.4660
Problem: Cursorcolumn is sometimes not correct.
Solution: Recompute the cursor column when entering Insert mode and the
cursor is on a character wider than a screen cell.
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/edit.c b/src/edit.c index 0edd38be4..c52583a8b 100644 --- a/src/edit.c +++ b/src/edit.c @@ -293,11 +293,14 @@ edit( conceal_check_cursor_line(cursor_line_was_concealed); #endif - /* - * Need to recompute the cursor position, it might move when the cursor is - * on a TAB or special character. - */ - curs_columns(TRUE); + // Need to recompute the cursor position, it might move when the cursor + // is on a TAB or special character. + // ptr2cells() treats a TAB character as double-width. + if (ptr2cells(ml_get_cursor()) > 1) + { + curwin->w_valid &= ~VALID_VIRTCOL; + curs_columns(TRUE); + } /* * Enable langmap or IME, indicated by 'iminsert'. |