summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-07-19 22:09:06 +0200
committerBram Moolenaar <Bram@vim.org>2020-07-19 22:09:06 +0200
commit54c3fcd852f9d986f81547429e850b3364f058d6 (patch)
treed5700d0f8f7637aec2b86b5c599ee8af411a51e2
parent682d0a15462f3d4f9404e98a56b340ae131cbb09 (diff)
downloadvim-git-8.2.1252.tar.gz
patch 8.2.1252: ":marks" may show '< and '> mixed upv8.2.1252
Problem: ":marks" may show '< and '> mixed up. Solution: Show the mark position as where '< and '> would jump.
-rw-r--r--src/mark.c14
-rw-r--r--src/testdir/test_marks.vim48
-rw-r--r--src/version.c2
3 files changed, 43 insertions, 21 deletions
diff --git a/src/mark.c b/src/mark.c
index 948a1826e..aa9445ed0 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -704,6 +704,7 @@ ex_marks(exarg_T *eap)
char_u *arg = eap->arg;
int i;
char_u *name;
+ pos_T *posp, *startp, *endp;
if (arg != NULL && *arg == NUL)
arg = NULL;
@@ -731,8 +732,17 @@ ex_marks(exarg_T *eap)
show_one_mark(']', arg, &curbuf->b_op_end, NULL, TRUE);
show_one_mark('^', arg, &curbuf->b_last_insert, NULL, TRUE);
show_one_mark('.', arg, &curbuf->b_last_change, NULL, TRUE);
- show_one_mark('<', arg, &curbuf->b_visual.vi_start, NULL, TRUE);
- show_one_mark('>', arg, &curbuf->b_visual.vi_end, NULL, TRUE);
+
+ // Show the marks as where they will jump to.
+ startp = &curbuf->b_visual.vi_start;
+ endp = &curbuf->b_visual.vi_end;
+ if ((LT_POS(*startp, *endp) || endp->lnum == 0) && startp->lnum != 0)
+ posp = startp;
+ else
+ posp = endp;
+ show_one_mark('<', arg, posp, NULL, TRUE);
+ show_one_mark('>', arg, posp == startp ? endp : startp, NULL, TRUE);
+
show_one_mark(-1, arg, NULL, NULL, FALSE);
}
diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim
index e4ab562fd..40242c083 100644
--- a/src/testdir/test_marks.vim
+++ b/src/testdir/test_marks.vim
@@ -105,33 +105,43 @@ func Test_marks_cmd()
new Xtwo
call setline(1, ['ccc', 'ddd'])
norm! $mcGmD
+ exe "norm! GVgg\<Esc>G"
w!
b Xone
let a = split(execute('marks'), "\n")
call assert_equal(9, len(a))
- call assert_equal('mark line col file/text', a[0])
- call assert_equal(" ' 2 0 bbb", a[1])
- call assert_equal(' a 1 0 aaa', a[2])
- call assert_equal(' B 2 2 bbb', a[3])
- call assert_equal(' D 2 0 Xtwo', a[4])
- call assert_equal(' " 1 0 aaa', a[5])
- call assert_equal(' [ 1 0 aaa', a[6])
- call assert_equal(' ] 2 0 bbb', a[7])
- call assert_equal(' . 2 0 bbb', a[8])
+ call assert_equal(['mark line col file/text',
+ \ " ' 2 0 bbb",
+ \ ' a 1 0 aaa',
+ \ ' B 2 2 bbb',
+ \ ' D 2 0 Xtwo',
+ \ ' " 1 0 aaa',
+ \ ' [ 1 0 aaa',
+ \ ' ] 2 0 bbb',
+ \ ' . 2 0 bbb'], a)
b Xtwo
let a = split(execute('marks'), "\n")
- call assert_equal(9, len(a))
- call assert_equal('mark line col file/text', a[0])
- call assert_equal(" ' 1 0 ccc", a[1])
- call assert_equal(' c 1 2 ccc', a[2])
- call assert_equal(' B 2 2 Xone', a[3])
- call assert_equal(' D 2 0 ddd', a[4])
- call assert_equal(' " 2 0 ddd', a[5])
- call assert_equal(' [ 1 0 ccc', a[6])
- call assert_equal(' ] 2 0 ddd', a[7])
- call assert_equal(' . 2 0 ddd', a[8])
+ call assert_equal(11, len(a))
+ call assert_equal(['mark line col file/text',
+ \ " ' 1 0 ccc",
+ \ ' c 1 2 ccc',
+ \ ' B 2 2 Xone',
+ \ ' D 2 0 ddd',
+ \ ' " 2 0 ddd',
+ \ ' [ 1 0 ccc',
+ \ ' ] 2 0 ddd',
+ \ ' . 2 0 ddd',
+ \ ' < 1 0 ccc',
+ \ ' > 2 0 ddd'], a)
+ norm! Gdd
+ w!
+ let a = split(execute('marks <>'), "\n")
+ call assert_equal(3, len(a))
+ call assert_equal(['mark line col file/text',
+ \ ' < 1 0 ccc',
+ \ ' > 2 0 -invalid-'], a)
b Xone
delmarks aB
diff --git a/src/version.c b/src/version.c
index 444870e3f..89fd04345 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1252,
+/**/
1251,
/**/
1250,