patch 8.2.4660: cursorcolumn is sometimes not correct
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.
diff --git a/src/edit.c b/src/edit.c
index 0edd38b..c52583a 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -293,11 +293,14 @@
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'.