diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-01 14:14:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-01 14:14:44 +0200 |
commit | f17e7ea67a798d0aa45ce24ea80c9e21d5164326 (patch) | |
tree | 6ee60025d1c4aa335d760d81fa211da0ed742eed | |
parent | ad772a63ec3bc86fe9d53cba783812f53470a313 (diff) |
patch 8.2.0871: cannot use getmarklist() as a methodv8.2.0871
Problem: Cannot use getmarklist() as a method.
Solution: Make getmarklist() work as a method. Add one to the column
number to match getpos(). (Yegappan Lakshmanan, closes #6176)
-rw-r--r-- | runtime/doc/eval.txt | 2 | ||||
-rw-r--r-- | src/evalfunc.c | 2 | ||||
-rw-r--r-- | src/mark.c | 2 | ||||
-rw-r--r-- | src/testdir/test_marks.vim | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 13 insertions, 9 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fb0b2a7896..7582a27240 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5385,6 +5385,8 @@ getmarklist([{expr}] *getmarklist()* Refer to |getpos()| for getting information about a specific mark. + Can also be used as a |method|: > + GetBufnr()->getmarklist() getmatches([{win}]) *getmatches()* Returns a |List| with all matches previously defined for the diff --git a/src/evalfunc.c b/src/evalfunc.c index 92d6c06671..92cd4a44f7 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -579,7 +579,7 @@ static funcentry_T global_functions[] = {"getjumplist", 0, 2, FEARG_1, ret_list_any, f_getjumplist}, {"getline", 1, 2, FEARG_1, ret_f_getline, f_getline}, {"getloclist", 1, 2, 0, ret_list_dict_any, f_getloclist}, - {"getmarklist", 0, 1, 0, ret_list_dict_any, f_getmarklist}, + {"getmarklist", 0, 1, FEARG_1, ret_list_dict_any, f_getmarklist}, {"getmatches", 0, 1, 0, ret_list_dict_any, f_getmatches}, {"getmousepos", 0, 0, 0, ret_dict_number, f_getmousepos}, {"getpid", 0, 0, 0, ret_number, f_getpid}, diff --git a/src/mark.c b/src/mark.c index ca64c90e14..298da67e84 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1442,7 +1442,7 @@ add_mark(list_T *l, char_u *mname, pos_T *pos, int bufnr, char_u *fname) list_append_number(lpos, bufnr); list_append_number(lpos, pos->lnum); - list_append_number(lpos, pos->col); + list_append_number(lpos, pos->col + 1); list_append_number(lpos, pos->coladd); if (dict_add_string(d, "mark", mname) == FAIL diff --git a/src/testdir/test_marks.vim b/src/testdir/test_marks.vim index ffd50a12ca..e4ab562fd6 100644 --- a/src/testdir/test_marks.vim +++ b/src/testdir/test_marks.vim @@ -269,18 +269,18 @@ func Test_getmarklist() mark A call cursor(3, 5) normal mN - call assert_equal([{'file' : '', 'mark' : "'A", 'pos' : [bufnr(), 1, 0, 0]}, - \ {'file' : '', 'mark' : "'N", 'pos' : [bufnr(), 3, 4, 0]}], + call assert_equal([{'file' : '', 'mark' : "'A", 'pos' : [bufnr(), 1, 1, 0]}, + \ {'file' : '', 'mark' : "'N", 'pos' : [bufnr(), 3, 5, 0]}], \ getmarklist()) " buffer local marks delmarks! - call assert_equal([{'mark' : "''", 'pos' : [bufnr(), 1, 0, 0]}, - \ {'mark' : "'\"", 'pos' : [bufnr(), 1, 0, 0]}], getmarklist(bufnr())) + call assert_equal([{'mark' : "''", 'pos' : [bufnr(), 1, 1, 0]}, + \ {'mark' : "'\"", 'pos' : [bufnr(), 1, 1, 0]}], getmarklist(bufnr())) call cursor(2, 2) normal mr - call assert_equal({'mark' : "'r", 'pos' : [bufnr(), 2, 1, 0]}, - \ getmarklist(bufnr())[0]) - call assert_equal([], getmarklist({})) + call assert_equal({'mark' : "'r", 'pos' : [bufnr(), 2, 2, 0]}, + \ bufnr()->getmarklist()[0]) + call assert_equal([], {}->getmarklist()) close! endfunc diff --git a/src/version.c b/src/version.c index e51e65021f..7138ac5257 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 871, +/**/ 870, /**/ 869, |