]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0880: scroll: window scrolls when using the autocommand window v9.2.0880
authorHirohito Higashi <h.east.727@gmail.com>
Thu, 30 Jul 2026 19:28:04 +0000 (19:28 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 30 Jul 2026 19:28:45 +0000 (19:28 +0000)
Problem:  The window scrolls when an autocommand window is used while the
          cursor is behind multi-byte characters.
Solution: Use the byte column instead of the character count when computing
          how many screen lines the text up to the cursor takes.

fixes:  #12085
closes: #20884

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/todo.txt
src/misc1.c
src/testdir/test_window_cmd.vim
src/version.c

index f265b39689e9c7dc30b913c81e2a14c0729516c7..9c8c0f4933da2da3c3731464a8ba625769316c21 100644 (file)
@@ -1,4 +1,4 @@
-*todo.txt*     For Vim version 9.2.  Last change: 2026 Jun 23
+*todo.txt*     For Vim version 9.2.  Last change: 2026 Jul 30
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -40,10 +40,10 @@ Mapping with modifier is not recognized after a partial mapping.  Probably
 because the typeahead was simplified when looking for a matching mapping.
 Need to somehow undo the simplification.  #12002
 
-Windows scroll when using the autocmd window.  #12085
-in restore_snapshot_rec() restore more values from the snapshot, instead of
-calling frame_new_height() and frame_new_width(), especially w_topline and
-w_skipcol.
+Using the autocmd window resets w_skipcol when the cursor is in a long
+wrapped line.  In restore_snapshot_rec() restore more values from the
+snapshot, instead of calling frame_new_height() and frame_new_width(),
+especially w_skipcol.
 
 Check places that source "path/*.vim" to not match other extensions, e.g.
 .vim9, on MS-Windows (short file name match, gets expanded to long file name).
index c09ae8127548751d11a2ff4f5bcac5aa5eadc869..6ba215500d1ffd1769c68998a2b3889fb8a4ef0f 100644 (file)
@@ -439,7 +439,7 @@ plines_win_nofold(win_T *wp, linenr_T lnum)
 
 /*
  * Like plines_win(), but only reports the number of physical screen lines
- * used from the start of the line to the given column number.
+ * used from the start of the line to the given byte column.
  */
     int
 plines_win_col(win_T *wp, linenr_T lnum, long column)
@@ -465,7 +465,8 @@ plines_win_col(win_T *wp, linenr_T lnum, long column)
     line = ml_get_buf(wp->w_buffer, lnum, FALSE);
 
     init_chartabsize_arg(&cts, wp, lnum, 0, line, line);
-    while (*cts.cts_ptr != NUL && --column >= 0)
+    // "column" is a byte index, advance the pointer until it is reached.
+    while (*cts.cts_ptr != NUL && cts.cts_ptr < line + column)
     {
        cts.cts_vcol += win_lbr_chartabsize(&cts, NULL, NULL);
        MB_PTR_ADV(cts.cts_ptr);
index bf524030f9141b01fb455a885ea50a6ce9690fc7..701eec65c40925c2371e1fa52727afb0bbebe072 100644 (file)
@@ -2034,6 +2034,24 @@ func Test_splitkeep_cmdheight()
   set splitkeep& cmdheight&
 endfunc
 
+func Test_aucmd_win_scroll_multibyte()
+  " Using the autocommand window must not scroll the current window when the
+  " cursor is behind multi-byte characters.
+  set splitkeep=cursor
+  call setline(1, repeat([repeat(nr2char(0x3042), 200)], 20))
+  normal! G0100l
+  redraw
+  let topline = line('w0')
+
+  for i in range(3)
+    call bufload(bufadd(''))
+  endfor
+  call assert_equal(topline, line('w0'))
+
+  %bwipeout!
+  set splitkeep&
+endfunc
+
 func Test_splitkeep_cursor()
   CheckScreendump
   let lines =<< trim END
index 5bc24b40a030f23ee040fe4a8f6c3a278611533e..caef0f750aeef2a1b47e4a076d9cd76003bce87c 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    880,
 /**/
     879,
 /**/