]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1612: "skipcol" not reset when using multi-byte characters v9.0.1612
authorBram Moolenaar <Bram@vim.org>
Mon, 5 Jun 2023 19:44:55 +0000 (20:44 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 5 Jun 2023 19:44:55 +0000 (20:44 +0100)
Problem:    "skipcol" not reset when using multi-byte characters.
Solution:   Compare with w_virtcol instead of w_cursor.col. (closes #12457)

src/move.c
src/testdir/dumps/Test_smoothscroll_multi_1.dump [new file with mode: 0644]
src/testdir/test_scroll_opt.vim
src/version.c

index 4cd4d1c2bcf0f221217a573c4740f4e20bf6ad2c..ea7d38005672483ca1f0222922e969e7e3f0f85e 100644 (file)
@@ -2414,10 +2414,14 @@ scroll_cursor_top(int min_scroll, int always)
        }
        check_topfill(curwin, FALSE);
 #endif
-       // TODO: if the line doesn't fit may optimize w_skipcol
-       if (curwin->w_topline == curwin->w_cursor.lnum
-               && curwin->w_skipcol >= curwin->w_cursor.col)
-           reset_skipcol();
+       if (curwin->w_topline == curwin->w_cursor.lnum)
+       {
+           validate_virtcol();
+           if (curwin->w_skipcol >= curwin->w_virtcol)
+               // TODO: if the line doesn't fit may optimize w_skipcol instead
+               // of making it zero
+               reset_skipcol();
+       }
        if (curwin->w_topline != old_topline
                || curwin->w_skipcol != old_skipcol
 #ifdef FEAT_DIFF
diff --git a/src/testdir/dumps/Test_smoothscroll_multi_1.dump b/src/testdir/dumps/Test_smoothscroll_multi_1.dump
new file mode 100644 (file)
index 0000000..21c73bc
--- /dev/null
@@ -0,0 +1,6 @@
+|ϛ+0&#ffffff0@34>ϛ@4
+@5| @34
+|2@35| @3
+|~+0#4040ff13&| @38
+|~| @38
+| +0#0000000&@21|1|,|7|1|-|3|6| @6|A|l@1| 
index f8b4b4f09ee031ba1f57671cd804a505ed1e4cfa..460416665d7ff0b66f07d9397e8449d5d75cf0bc 100644 (file)
@@ -124,6 +124,21 @@ func Test_smoothscroll_CtrlE_CtrlY()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_smoothscroll_multibyte()
+  CheckScreendump
+
+  let lines =<< trim END
+      set scrolloff=0 smoothscroll
+      call setline(1, [repeat('ϛ', 45), repeat('2', 36)])
+      exe "normal G35l\<C-E>k"
+  END
+  call writefile(lines, 'XSmoothMultibyte', 'D')
+  let buf = RunVimInTerminal('-S XSmoothMultibyte', #{rows: 6, cols: 40})
+  call VerifyScreenDump(buf, 'Test_smoothscroll_multi_1', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_smoothscroll_number()
   CheckScreendump
 
index 2e3c240f6e849212e0c1432b395c1847f8f2645a..a0c6893ee0ff4c839b32d4fabf2965b87f7d8d05 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1612,
 /**/
     1611,
 /**/