]> granicus.if.org Git - vim/commitdiff
patch 8.1.0859: "%v" in 'errorformat' does handle multi-byte characters v8.1.0859
authorBram Moolenaar <Bram@vim.org>
Thu, 31 Jan 2019 13:27:04 +0000 (14:27 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 31 Jan 2019 13:27:04 +0000 (14:27 +0100)
Problem:    "%v" in 'errorformat' does handle multi-byte characters.
Solution:   Handle multi-byte characters. (Yegappan Lakshmanan, closes #3700)

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index e292819f2ec0d59906ab67386503b013814271fa..3bfa027d6209742d0bb06d76687d0100af975124 100644 (file)
@@ -3047,9 +3047,6 @@ qf_jump_goto_line(
        char_u          *qf_pattern)
 {
     linenr_T           i;
-    char_u             *line;
-    colnr_T            screen_col;
-    colnr_T            char_col;
 
     if (qf_pattern == NULL)
     {
@@ -3063,29 +3060,11 @@ qf_jump_goto_line(
        }
        if (qf_col > 0)
        {
-           curwin->w_cursor.col = qf_col - 1;
            curwin->w_cursor.coladd = 0;
            if (qf_viscol == TRUE)
-           {
-               // Check each character from the beginning of the error
-               // line up to the error column.  For each tab character
-               // found, reduce the error column value by the length of
-               // a tab character.
-               line = ml_get_curline();
-               screen_col = 0;
-               for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col)
-               {
-                   if (*line == NUL)
-                       break;
-                   if (*line++ == '\t')
-                   {
-                       curwin->w_cursor.col -= 7 - (screen_col % 8);
-                       screen_col += 8 - (screen_col % 8);
-                   }
-                   else
-                       ++screen_col;
-               }
-           }
+               coladvance(qf_col - 1);
+           else
+               curwin->w_cursor.col = qf_col - 1;
            curwin->w_set_curswant = TRUE;
            check_cursor();
        }
index db2a8e6c5de7384cd62f8945c33ad42dde2284b1..e7aa41ebf93a083fb5164657672d4e6032bfd59e 100644 (file)
@@ -3843,3 +3843,59 @@ func Test_splitview()
   call delete('Xtestfile1')
   call delete('Xtestfile2')
 endfunc
+
+" Test for parsing entries using visual screen column
+func Test_viscol()
+  enew
+  call writefile(["Col1\tCol2\tCol3"], 'Xfile1')
+  edit Xfile1
+
+  " Use byte offset for column number
+  set efm&
+  cexpr "Xfile1:1:5:XX\nXfile1:1:9:YY\nXfile1:1:20:ZZ"
+  call assert_equal([5, 8], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([9, 12], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([14, 20], [col('.'), virtcol('.')])
+
+  " Use screen column offset for column number
+  set efm=%f:%l:%v:%m
+  cexpr "Xfile1:1:8:XX\nXfile1:1:12:YY\nXfile1:1:20:ZZ"
+  call assert_equal([5, 8], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([9, 12], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([14, 20], [col('.'), virtcol('.')])
+  cexpr "Xfile1:1:6:XX\nXfile1:1:15:YY\nXfile1:1:24:ZZ"
+  call assert_equal([5, 8], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([10, 16], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([14, 20], [col('.'), virtcol('.')])
+
+  enew
+  call writefile(["Col1\täü\töß\tCol4"], 'Xfile1')
+
+  " Use byte offset for column number
+  set efm&
+  cexpr "Xfile1:1:8:XX\nXfile1:1:11:YY\nXfile1:1:16:ZZ"
+  call assert_equal([8, 10], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([11, 17], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([16, 25], [col('.'), virtcol('.')])
+
+  " Use screen column offset for column number
+  set efm=%f:%l:%v:%m
+  cexpr "Xfile1:1:10:XX\nXfile1:1:17:YY\nXfile1:1:25:ZZ"
+  call assert_equal([8, 10], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([11, 17], [col('.'), virtcol('.')])
+  cnext
+  call assert_equal([16, 25], [col('.'), virtcol('.')])
+
+  enew | only
+  set efm&
+  call delete('Xfile1')
+endfunc
index 9422f8426c260e26736b08b650a31f86caf960ab..ed4c1b54d0e4e6d30581367a5240ed457402004c 100644 (file)
@@ -783,6 +783,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    859,
 /**/
     858,
 /**/