Skip to content

Commit 54c3fcd

Browse files
committed
patch 8.2.1252: ":marks" may show '< and '> mixed up
Problem: ":marks" may show '< and '> mixed up. Solution: Show the mark position as where '< and '> would jump.
1 parent 682d0a1 commit 54c3fcd

3 files changed

Lines changed: 43 additions & 21 deletions

File tree

src/mark.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ ex_marks(exarg_T *eap)
704704
char_u *arg = eap->arg;
705705
int i;
706706
char_u *name;
707+
pos_T *posp, *startp, *endp;
707708

708709
if (arg != NULL && *arg == NUL)
709710
arg = NULL;
@@ -731,8 +732,17 @@ ex_marks(exarg_T *eap)
731732
show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE);
732733
show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE);
733734
show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE);
734-
show_one_mark('<', arg, &curbuf->b_visual.vi_start, NULL, TRUE);
735-
show_one_mark('>', arg, &curbuf->b_visual.vi_end, NULL, TRUE);
735+
736+
// Show the marks as where they will jump to.
737+
startp = &curbuf->b_visual.vi_start;
738+
endp = &curbuf->b_visual.vi_end;
739+
if ((LT_POS(*startp, *endp) || endp->lnum == 0) && startp->lnum != 0)
740+
posp = startp;
741+
else
742+
posp = endp;
743+
show_one_mark('<', arg, posp, NULL, TRUE);
744+
show_one_mark('>', arg, posp == startp ? endp : startp, NULL, TRUE);
745+
736746
show_one_mark(-1, arg, NULL, NULL, FALSE);
737747
}
738748

src/testdir/test_marks.vim

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,43 @@ func Test_marks_cmd()
105105
new Xtwo
106106
call setline(1, ['ccc', 'ddd'])
107107
norm! $mcGmD
108+
exe "norm! GVgg\<Esc>G"
108109
w!
109110

110111
b Xone
111112
let a = split(execute('marks'), "\n")
112113
call assert_equal(9, len(a))
113-
call assert_equal('mark line col file/text', a[0])
114-
call assert_equal(" ' 2 0 bbb", a[1])
115-
call assert_equal(' a 1 0 aaa', a[2])
116-
call assert_equal(' B 2 2 bbb', a[3])
117-
call assert_equal(' D 2 0 Xtwo', a[4])
118-
call assert_equal(' " 1 0 aaa', a[5])
119-
call assert_equal(' [ 1 0 aaa', a[6])
120-
call assert_equal(' ] 2 0 bbb', a[7])
121-
call assert_equal(' . 2 0 bbb', a[8])
114+
call assert_equal(['mark line col file/text',
115+
\ " ' 2 0 bbb",
116+
\ ' a 1 0 aaa',
117+
\ ' B 2 2 bbb',
118+
\ ' D 2 0 Xtwo',
119+
\ ' " 1 0 aaa',
120+
\ ' [ 1 0 aaa',
121+
\ ' ] 2 0 bbb',
122+
\ ' . 2 0 bbb'], a)
122123

123124
b Xtwo
124125
let a = split(execute('marks'), "\n")
125-
call assert_equal(9, len(a))
126-
call assert_equal('mark line col file/text', a[0])
127-
call assert_equal(" ' 1 0 ccc", a[1])
128-
call assert_equal(' c 1 2 ccc', a[2])
129-
call assert_equal(' B 2 2 Xone', a[3])
130-
call assert_equal(' D 2 0 ddd', a[4])
131-
call assert_equal(' " 2 0 ddd', a[5])
132-
call assert_equal(' [ 1 0 ccc', a[6])
133-
call assert_equal(' ] 2 0 ddd', a[7])
134-
call assert_equal(' . 2 0 ddd', a[8])
126+
call assert_equal(11, len(a))
127+
call assert_equal(['mark line col file/text',
128+
\ " ' 1 0 ccc",
129+
\ ' c 1 2 ccc',
130+
\ ' B 2 2 Xone',
131+
\ ' D 2 0 ddd',
132+
\ ' " 2 0 ddd',
133+
\ ' [ 1 0 ccc',
134+
\ ' ] 2 0 ddd',
135+
\ ' . 2 0 ddd',
136+
\ ' < 1 0 ccc',
137+
\ ' > 2 0 ddd'], a)
138+
norm! Gdd
139+
w!
140+
let a = split(execute('marks <>'), "\n")
141+
call assert_equal(3, len(a))
142+
call assert_equal(['mark line col file/text',
143+
\ ' < 1 0 ccc',
144+
\ ' > 2 0 -invalid-'], a)
135145

136146
b Xone
137147
delmarks aB

src/version.c

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

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1252,
757759
/**/
758760
1251,
759761
/**/

0 commit comments

Comments
 (0)