Skip to content

Commit c45eb77

Browse files
committed
patch 8.1.0859: "%v" in 'errorformat' does handle multi-byte characters
Problem: "%v" in 'errorformat' does handle multi-byte characters. Solution: Handle multi-byte characters. (Yegappan Lakshmanan, closes #3700)
1 parent ce65574 commit c45eb77

3 files changed

Lines changed: 61 additions & 24 deletions

File tree

src/quickfix.c

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,9 +3047,6 @@ qf_jump_goto_line(
30473047
char_u *qf_pattern)
30483048
{
30493049
linenr_T i;
3050-
char_u *line;
3051-
colnr_T screen_col;
3052-
colnr_T char_col;
30533050

30543051
if (qf_pattern == NULL)
30553052
{
@@ -3063,29 +3060,11 @@ qf_jump_goto_line(
30633060
}
30643061
if (qf_col > 0)
30653062
{
3066-
curwin->w_cursor.col = qf_col - 1;
30673063
curwin->w_cursor.coladd = 0;
30683064
if (qf_viscol == TRUE)
3069-
{
3070-
// Check each character from the beginning of the error
3071-
// line up to the error column. For each tab character
3072-
// found, reduce the error column value by the length of
3073-
// a tab character.
3074-
line = ml_get_curline();
3075-
screen_col = 0;
3076-
for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col)
3077-
{
3078-
if (*line == NUL)
3079-
break;
3080-
if (*line++ == '\t')
3081-
{
3082-
curwin->w_cursor.col -= 7 - (screen_col % 8);
3083-
screen_col += 8 - (screen_col % 8);
3084-
}
3085-
else
3086-
++screen_col;
3087-
}
3088-
}
3065+
coladvance(qf_col - 1);
3066+
else
3067+
curwin->w_cursor.col = qf_col - 1;
30893068
curwin->w_set_curswant = TRUE;
30903069
check_cursor();
30913070
}

src/testdir/test_quickfix.vim

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,3 +3843,59 @@ func Test_splitview()
38433843
call delete('Xtestfile1')
38443844
call delete('Xtestfile2')
38453845
endfunc
3846+
3847+
" Test for parsing entries using visual screen column
3848+
func Test_viscol()
3849+
enew
3850+
call writefile(["Col1\tCol2\tCol3"], 'Xfile1')
3851+
edit Xfile1
3852+
3853+
" Use byte offset for column number
3854+
set efm&
3855+
cexpr "Xfile1:1:5:XX\nXfile1:1:9:YY\nXfile1:1:20:ZZ"
3856+
call assert_equal([5, 8], [col('.'), virtcol('.')])
3857+
cnext
3858+
call assert_equal([9, 12], [col('.'), virtcol('.')])
3859+
cnext
3860+
call assert_equal([14, 20], [col('.'), virtcol('.')])
3861+
3862+
" Use screen column offset for column number
3863+
set efm=%f:%l:%v:%m
3864+
cexpr "Xfile1:1:8:XX\nXfile1:1:12:YY\nXfile1:1:20:ZZ"
3865+
call assert_equal([5, 8], [col('.'), virtcol('.')])
3866+
cnext
3867+
call assert_equal([9, 12], [col('.'), virtcol('.')])
3868+
cnext
3869+
call assert_equal([14, 20], [col('.'), virtcol('.')])
3870+
cexpr "Xfile1:1:6:XX\nXfile1:1:15:YY\nXfile1:1:24:ZZ"
3871+
call assert_equal([5, 8], [col('.'), virtcol('.')])
3872+
cnext
3873+
call assert_equal([10, 16], [col('.'), virtcol('.')])
3874+
cnext
3875+
call assert_equal([14, 20], [col('.'), virtcol('.')])
3876+
3877+
enew
3878+
call writefile(["Col1\täü\töß\tCol4"], 'Xfile1')
3879+
3880+
" Use byte offset for column number
3881+
set efm&
3882+
cexpr "Xfile1:1:8:XX\nXfile1:1:11:YY\nXfile1:1:16:ZZ"
3883+
call assert_equal([8, 10], [col('.'), virtcol('.')])
3884+
cnext
3885+
call assert_equal([11, 17], [col('.'), virtcol('.')])
3886+
cnext
3887+
call assert_equal([16, 25], [col('.'), virtcol('.')])
3888+
3889+
" Use screen column offset for column number
3890+
set efm=%f:%l:%v:%m
3891+
cexpr "Xfile1:1:10:XX\nXfile1:1:17:YY\nXfile1:1:25:ZZ"
3892+
call assert_equal([8, 10], [col('.'), virtcol('.')])
3893+
cnext
3894+
call assert_equal([11, 17], [col('.'), virtcol('.')])
3895+
cnext
3896+
call assert_equal([16, 25], [col('.'), virtcol('.')])
3897+
3898+
enew | only
3899+
set efm&
3900+
call delete('Xfile1')
3901+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ static char *(features[]) =
783783

784784
static int included_patches[] =
785785
{ /* Add new patch number below this line */
786+
/**/
787+
859,
786788
/**/
787789
858,
788790
/**/

0 commit comments

Comments
 (0)