diff src/edit.c @ 28269:20b28fbf7f03 v8.2.4660

patch 8.2.4660: cursorcolumn is sometimes not correct Commit: https://github.com/vim/vim/commit/782c6744b49b30d9460ed00d4773666e42e07163 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Apr 1 12:06:31 2022 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Fri, 01 Apr 2022 13:15:08 +0200
parents c99005ffa8c3
children a9a56b567709
line wrap: on
line diff
--- 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'.