]> granicus.if.org Git - vim/commitdiff
patch 8.2.3903: "gM" does not count tabs as expected v8.2.3903
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Dec 2021 15:00:07 +0000 (15:00 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Dec 2021 15:00:07 +0000 (15:00 +0000)
Problem:    "gM" does not count tabs as expected.
Solution:   Use linetabsize() instead of mb_string2cells(). (closes #9409)

src/normal.c
src/testdir/test_normal.vim
src/version.c

index 1e887ca91143f5a9d7229ceb109574a801439633..f925aa14ab7253b6d3c4194380a694360c1cab0d 100644 (file)
@@ -6122,14 +6122,9 @@ nv_g_cmd(cmdarg_T *cap)
 
     case 'M':
        {
-           char_u  *ptr = ml_get_curline();
-
            oap->motion_type = MCHAR;
            oap->inclusive = FALSE;
-           if (has_mbyte)
-               i = mb_string2cells(ptr, (int)STRLEN(ptr));
-           else
-               i = (int)STRLEN(ptr);
+           i = linetabsize(ml_get_curline());
            if (cap->count0 > 0 && cap->count0 <= 100)
                coladvance((colnr_T)(i * cap->count0 / 100));
            else
index 6458a1bed4853d8d971917e87397a21e3e3298df..9794961337f4f76dfe5673fb5f2e3023208f3435 100644 (file)
@@ -2580,7 +2580,15 @@ func Test_normal33_g_cmd2()
   call assert_equal(87, col('.'))
   call assert_equal('E', getreg(0))
 
+  " Test for gM with Tab characters
+  call setline('.', "\ta\tb\tc\td\te\tf")
+  norm! gMyl
+  call assert_equal(6, col('.'))
+  call assert_equal("c", getreg(0))
+
   " Test for g Ctrl-G
+  call setline('.', lineC)
+  norm! 60gMyl
   set ff=unix
   let a=execute(":norm! g\<c-g>")
   call assert_match('Col 87 of 144; Line 2 of 2; Word 1 of 1; Byte 88 of 146', a)
index 55ddb069c87463b2bb5020b16d749ff343d5b54b..7d5d6b593eb1ce66d6a7bd51d93973e20a847438 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3903,
 /**/
     3902,
 /**/