Skip to content

Commit 9d5185b

Browse files
committed
patch 8.1.0168: output of :marks is too short with multi-byte chars
Problem: Output of :marks is too short with multi-byte chars. (Tony Mechelynck) Solution: Get more bytes from the text line.
1 parent c89d4b3 commit 9d5185b

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/mark.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,11 @@ mark_line(pos_T *mp, int lead_len)
686686

687687
if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count)
688688
return vim_strsave((char_u *)"-invalid-");
689-
s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (int)Columns);
689+
// Allow for up to 5 bytes per character.
690+
s = vim_strnsave(skipwhite(ml_get(mp->lnum)), (int)Columns * 5);
690691
if (s == NULL)
691692
return NULL;
692-
/* Truncate the line to fit it in the window */
693+
// Truncate the line to fit it in the window.
693694
len = 0;
694695
for (p = s; *p != NUL; MB_PTR_ADV(p))
695696
{

src/testdir/test_marks.vim

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func Test_marks_cmd()
8080
w!
8181

8282
b Xone
83-
let a=split(execute('marks'), "\n")
83+
let a = split(execute('marks'), "\n")
8484
call assert_equal(9, len(a))
8585
call assert_equal('mark line col file/text', a[0])
8686
call assert_equal(" ' 2 0 bbb", a[1])
@@ -93,7 +93,7 @@ func Test_marks_cmd()
9393
call assert_equal(' . 2 0 bbb', a[8])
9494

9595
b Xtwo
96-
let a=split(execute('marks'), "\n")
96+
let a = split(execute('marks'), "\n")
9797
call assert_equal(9, len(a))
9898
call assert_equal('mark line col file/text', a[0])
9999
call assert_equal(" ' 1 0 ccc", a[1])
@@ -107,7 +107,7 @@ func Test_marks_cmd()
107107

108108
b Xone
109109
delmarks aB
110-
let a=split(execute('marks aBcD'), "\n")
110+
let a = split(execute('marks aBcD'), "\n")
111111
call assert_equal(2, len(a))
112112
call assert_equal('mark line col file/text', a[0])
113113
call assert_equal(' D 2 0 Xtwo', a[1])
@@ -120,3 +120,22 @@ func Test_marks_cmd()
120120
call delete('Xtwo')
121121
%bwipe
122122
endfunc
123+
124+
func Test_marks_cmd_multibyte()
125+
if !has('multi_byte')
126+
return
127+
endif
128+
new Xone
129+
call setline(1, ['ááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááááá'])
130+
norm! ma
131+
132+
let a = split(execute('marks a'), "\n")
133+
call assert_equal(2, len(a))
134+
let expected = ' a 1 0 '
135+
while strwidth(expected) < &columns - 1
136+
let expected .= 'á'
137+
endwhile
138+
call assert_equal(expected, a[1])
139+
140+
bwipe!
141+
endfunc

src/version.c

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

790790
static int included_patches[] =
791791
{ /* Add new patch number below this line */
792+
/**/
793+
168,
792794
/**/
793795
167,
794796
/**/

0 commit comments

Comments
 (0)