From 83aed410b6fa4e807070b0af3bd89da4d29a812b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 18 May 2019 21:07:34 -0400 Subject: vim-patch:8.0.1082: tests fail when run under valgrind Problem: Tests fail when run under valgrind. Solution: Increase waiting times. https://github.com/vim/vim/commit/9d18961323a2a5c3b609c98ce0d78613c71f3532 --- src/nvim/testdir/test_clientserver.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim index 60ef20e0b2..02840de743 100644 --- a/src/nvim/testdir/test_clientserver.vim +++ b/src/nvim/testdir/test_clientserver.vim @@ -35,7 +35,8 @@ func Test_client_server() endif " Takes a short while for the server to be active. - call WaitFor('serverlist() =~ "' . name . '"') + " When using valgrind it takes much longer. + call WaitFor('serverlist() =~ "' . name . '"', 5000) call assert_match(name, serverlist()) call remote_foreground(name) -- cgit From 41828a7302d1ca17d5b84ff55aa9c91bd846ad64 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 07:42:41 -0400 Subject: vim-patch:8.0.1497: getting the jump list requires parsing the output of :jumps Problem: Getting the jump list requires parsing the output of :jumps. Solution: Add getjumplist(). (Yegappan Lakshmanan, closes vim/vim#2609) https://github.com/vim/vim/commit/4f50588ba336e7f086a72c53f5688c2494fc34b3 --- src/nvim/eval.c | 26 ++++++++++++++++ src/nvim/eval.lua | 1 + src/nvim/testdir/test_jumplist.vim | 64 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 src/nvim/testdir/test_jumplist.vim (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 132450f7a1..d48161d736 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10051,6 +10051,32 @@ static void f_getftype(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_string = type; } +// "getjumplist()" function +static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + tv_list_alloc_ret(rettv, kListLenMayKnow); + const win_T *const wp = find_tabwin(&argvars[0], &argvars[1]); + if (wp == NULL) { + return; + } + + list_T *const l = tv_list_alloc(wp->w_jumplistlen); + tv_list_append_list(rettv->vval.v_list, l); + tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx); + + for (int i = 0; i < wp->w_jumplistlen; i++) { + dict_T *const d = tv_dict_alloc(); + tv_list_append_dict(l, d); + tv_dict_add_nr(d, S_LEN("lnum"), wp->w_jumplist[i].fmark.mark.lnum); + tv_dict_add_nr(d, S_LEN("col"), wp->w_jumplist[i].fmark.mark.col); + tv_dict_add_nr(d, S_LEN("coladd"), wp->w_jumplist[i].fmark.mark.coladd); + tv_dict_add_nr(d, S_LEN("bufnr"), wp->w_jumplist[i].fmark.fnum); + if (wp->w_jumplist[i].fmark.fnum == 0) { + tv_dict_add_str(d, S_LEN("filename"), (char *)wp->w_jumplist[i].fname); + } + } +} + /* * "getline(lnum, [end])" function */ diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index a7f8461fc3..d4bb69613e 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -131,6 +131,7 @@ return { getfsize={args=1}, getftime={args=1}, getftype={args=1}, + getjumplist={args={0, 2}}, getline={args={1, 2}}, getloclist={args={1, 2}}, getmatches={}, diff --git a/src/nvim/testdir/test_jumplist.vim b/src/nvim/testdir/test_jumplist.vim new file mode 100644 index 0000000000..7079d21aa4 --- /dev/null +++ b/src/nvim/testdir/test_jumplist.vim @@ -0,0 +1,64 @@ +" Tests for the jumplist functionality + +" Tests for the getjumplist() function +func Test_getjumplist() + if !has("jumplist") + return + endif + + %bwipe + clearjumps + call assert_equal([[], 0], getjumplist()) + call assert_equal([[], 0], getjumplist(1)) + call assert_equal([[], 0], getjumplist(1, 1)) + + call assert_equal([], getjumplist(100)) + call assert_equal([], getjumplist(1, 100)) + + let lines = [] + for i in range(1, 100) + call add(lines, "Line " . i) + endfor + call writefile(lines, "Xtest") + + " Jump around and create a jump list + edit Xtest + let bnr = bufnr('%') + normal 50% + normal G + normal gg + + call assert_equal([[ + \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4], + \ getjumplist()) + + " Traverse the jump list and verify the results + 5 + exe "normal \" + call assert_equal(2, getjumplist(1)[1]) + exe "normal 2\" + call assert_equal(0, getjumplist(1, 1)[1]) + exe "normal 3\" + call assert_equal(3, getjumplist()[1]) + exe "normal \" + normal 20% + call assert_equal([[ + \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0}, + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 5], + \ getjumplist()) + + let l = getjumplist() + call test_garbagecollect_now() + call assert_equal(5, l[1]) + clearjumps + call test_garbagecollect_now() + call assert_equal(5, l[1]) + + call delete("Xtest") +endfunc -- cgit From d6d9596b38f544faa23d2c831aa84a5d15ffa972 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 08:22:05 -0400 Subject: vim-patch:8.0.1498: getjumplist() returns duplicate entries Problem: Getjumplist() returns duplicate entries. (lacygoill) Solution: Call cleanup_jumplist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/a7e18d237f817637815f0de44b08df1e0ca0f4f9 --- src/nvim/eval.c | 11 ++++++-- src/nvim/mark.c | 58 ++++++++++++++++++-------------------- src/nvim/shada.c | 2 +- src/nvim/testdir/test_jumplist.vim | 6 ++-- 4 files changed, 40 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d48161d736..5c1c722a61 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10055,7 +10055,7 @@ static void f_getftype(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr) { tv_list_alloc_ret(rettv, kListLenMayKnow); - const win_T *const wp = find_tabwin(&argvars[0], &argvars[1]); + win_T *const wp = find_tabwin(&argvars[0], &argvars[1]); if (wp == NULL) { return; } @@ -10064,14 +10064,21 @@ static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr) tv_list_append_list(rettv->vval.v_list, l); tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx); + cleanup_jumplist(wp); for (int i = 0; i < wp->w_jumplistlen; i++) { + if (wp->w_jumplist[i].fmark.mark.lnum == 0) { + continue; + } + if (wp->w_jumplist[i].fmark.fnum == 0) { + fname2fnum(&wp->w_jumplist[i]); + } dict_T *const d = tv_dict_alloc(); tv_list_append_dict(l, d); tv_dict_add_nr(d, S_LEN("lnum"), wp->w_jumplist[i].fmark.mark.lnum); tv_dict_add_nr(d, S_LEN("col"), wp->w_jumplist[i].fmark.mark.col); tv_dict_add_nr(d, S_LEN("coladd"), wp->w_jumplist[i].fmark.mark.coladd); tv_dict_add_nr(d, S_LEN("bufnr"), wp->w_jumplist[i].fmark.fnum); - if (wp->w_jumplist[i].fmark.fnum == 0) { + if (wp->w_jumplist[i].fname != NULL) { tv_dict_add_str(d, S_LEN("filename"), (char *)wp->w_jumplist[i].fname); } } diff --git a/src/nvim/mark.c b/src/nvim/mark.c index ecd1f098ca..64b7b2e002 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -214,7 +214,7 @@ pos_T *movemark(int count) pos_T *pos; xfmark_T *jmp; - cleanup_jumplist(); + cleanup_jumplist(curwin); if (curwin->w_jumplistlen == 0) /* nothing to jump to */ return (pos_T *)NULL; @@ -463,7 +463,7 @@ getnextmark ( * This is used for marks obtained from the .shada file. It's postponed * until the mark is used to avoid a long startup delay. */ -static void fname2fnum(xfmark_T *fm) +void fname2fnum(xfmark_T *fm) { char_u *p; @@ -781,7 +781,7 @@ void ex_jumps(exarg_T *eap) int i; char_u *name; - cleanup_jumplist(); + cleanup_jumplist(curwin); /* Highlight title */ MSG_PUTS_TITLE(_("\n jump line col file/text")); for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) { @@ -1156,53 +1156,51 @@ void mark_col_adjust( } } -/* - * When deleting lines, this may create duplicate marks in the - * jumplist. They will be removed here for the current window. - */ -void cleanup_jumplist(void) +// When deleting lines, this may create duplicate marks in the +// jumplist. They will be removed here for the specified window. +void cleanup_jumplist(win_T *wp) { int i; int from, to; to = 0; - for (from = 0; from < curwin->w_jumplistlen; ++from) { - if (curwin->w_jumplistidx == from) - curwin->w_jumplistidx = to; - for (i = from + 1; i < curwin->w_jumplistlen; ++i) - if (curwin->w_jumplist[i].fmark.fnum - == curwin->w_jumplist[from].fmark.fnum - && curwin->w_jumplist[from].fmark.fnum != 0 - && curwin->w_jumplist[i].fmark.mark.lnum - == curwin->w_jumplist[from].fmark.mark.lnum) + for (from = 0; from < wp->w_jumplistlen; ++from) { + if (wp->w_jumplistidx == from) + wp->w_jumplistidx = to; + for (i = from + 1; i < wp->w_jumplistlen; ++i) + if (wp->w_jumplist[i].fmark.fnum + == wp->w_jumplist[from].fmark.fnum + && wp->w_jumplist[from].fmark.fnum != 0 + && wp->w_jumplist[i].fmark.mark.lnum + == wp->w_jumplist[from].fmark.mark.lnum) break; - if (i >= curwin->w_jumplistlen) { // no duplicate + if (i >= wp->w_jumplistlen) { // no duplicate if (to != from) { - // Not using curwin->w_jumplist[to++] = curwin->w_jumplist[from] because + // Not using wp->w_jumplist[to++] = wp->w_jumplist[from] because // this way valgrind complains about overlapping source and destination // in memcpy() call. (clang-3.6.0, debug build with -DEXITFREE). - curwin->w_jumplist[to] = curwin->w_jumplist[from]; + wp->w_jumplist[to] = wp->w_jumplist[from]; } to++; } else { - xfree(curwin->w_jumplist[from].fname); + xfree(wp->w_jumplist[from].fname); } } - if (curwin->w_jumplistidx == curwin->w_jumplistlen) { - curwin->w_jumplistidx = to; + if (wp->w_jumplistidx == wp->w_jumplistlen) { + wp->w_jumplistidx = to; } - curwin->w_jumplistlen = to; + wp->w_jumplistlen = to; // When pointer is below last jump, remove the jump if it matches the current // line. This avoids useless/phantom jumps. #9805 - if (curwin->w_jumplistlen - && curwin->w_jumplistidx == curwin->w_jumplistlen) { - const xfmark_T *fm_last = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; + if (wp->w_jumplistlen + && wp->w_jumplistidx == wp->w_jumplistlen) { + const xfmark_T *fm_last = &wp->w_jumplist[wp->w_jumplistlen - 1]; if (fm_last->fmark.fnum == curbuf->b_fnum - && fm_last->fmark.mark.lnum == curwin->w_cursor.lnum) { + && fm_last->fmark.mark.lnum == wp->w_cursor.lnum) { xfree(fm_last->fname); - curwin->w_jumplistlen--; - curwin->w_jumplistidx--; + wp->w_jumplistlen--; + wp->w_jumplistidx--; } } } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index eace4a524c..9f376ef9a0 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2739,7 +2739,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, // Initialize jump list const void *jump_iter = NULL; - cleanup_jumplist(); + cleanup_jumplist(curwin); setpcmark(); do { xfmark_T fm; diff --git a/src/nvim/testdir/test_jumplist.vim b/src/nvim/testdir/test_jumplist.vim index 7079d21aa4..02dbd76194 100644 --- a/src/nvim/testdir/test_jumplist.vim +++ b/src/nvim/testdir/test_jumplist.vim @@ -29,7 +29,6 @@ func Test_getjumplist() normal gg call assert_equal([[ - \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4], @@ -48,17 +47,16 @@ func Test_getjumplist() call assert_equal([[ \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, - \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 5], \ getjumplist()) let l = getjumplist() call test_garbagecollect_now() - call assert_equal(5, l[1]) + call assert_equal(4, l[1]) clearjumps call test_garbagecollect_now() - call assert_equal(5, l[1]) + call assert_equal(4, l[1]) call delete("Xtest") endfunc -- cgit From 4aad4c053366592f9604ecc6d3a1348005bf2ce7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 08:34:04 -0400 Subject: vim-patch:8.0.1513: the jumplist is not always properly cleaned up Problem: The jumplist is not always properly cleaned up. Solution: Call fname2fnum() before cleanup_jumplist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/486797413791f6be12dcec6e5faf4f952e4647ae --- src/nvim/eval.c | 6 ++---- src/nvim/mark.c | 24 ++++++++++++++++++------ src/nvim/shada.c | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 5c1c722a61..a7b74b322f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10064,14 +10064,12 @@ static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr) tv_list_append_list(rettv->vval.v_list, l); tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx); - cleanup_jumplist(wp); + cleanup_jumplist(wp, true); + for (int i = 0; i < wp->w_jumplistlen; i++) { if (wp->w_jumplist[i].fmark.mark.lnum == 0) { continue; } - if (wp->w_jumplist[i].fmark.fnum == 0) { - fname2fnum(&wp->w_jumplist[i]); - } dict_T *const d = tv_dict_alloc(); tv_list_append_dict(l, d); tv_dict_add_nr(d, S_LEN("lnum"), wp->w_jumplist[i].fmark.mark.lnum); diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 64b7b2e002..907cfe4833 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -214,7 +214,7 @@ pos_T *movemark(int count) pos_T *pos; xfmark_T *jmp; - cleanup_jumplist(curwin); + cleanup_jumplist(curwin, true); if (curwin->w_jumplistlen == 0) /* nothing to jump to */ return (pos_T *)NULL; @@ -463,7 +463,7 @@ getnextmark ( * This is used for marks obtained from the .shada file. It's postponed * until the mark is used to avoid a long startup delay. */ -void fname2fnum(xfmark_T *fm) +static void fname2fnum(xfmark_T *fm) { char_u *p; @@ -781,13 +781,11 @@ void ex_jumps(exarg_T *eap) int i; char_u *name; - cleanup_jumplist(curwin); + cleanup_jumplist(curwin, true); /* Highlight title */ MSG_PUTS_TITLE(_("\n jump line col file/text")); for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) { if (curwin->w_jumplist[i].fmark.mark.lnum != 0) { - if (curwin->w_jumplist[i].fmark.fnum == 0) - fname2fnum(&curwin->w_jumplist[i]); name = fm_getname(&curwin->w_jumplist[i].fmark, 16); if (name == NULL) /* file name not available */ continue; @@ -1158,11 +1156,25 @@ void mark_col_adjust( // When deleting lines, this may create duplicate marks in the // jumplist. They will be removed here for the specified window. -void cleanup_jumplist(win_T *wp) +// When "loadfiles" is true first ensure entries have the "fnum" field set +// (this may be a bit slow). +void cleanup_jumplist(win_T *wp, bool loadfiles) { int i; int from, to; + if (loadfiles) { + // If specified, load all the files from the jump list. This is + // needed to properly clean up duplicate entries, but will take some + // time. + for (i = 0; i < wp->w_jumplistlen; i++) { + if ((wp->w_jumplist[i].fmark.fnum == 0) + && (wp->w_jumplist[i].fmark.mark.lnum != 0)) { + fname2fnum(&wp->w_jumplist[i]); + } + } + } + to = 0; for (from = 0; from < wp->w_jumplistlen; ++from) { if (wp->w_jumplistidx == from) diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 9f376ef9a0..4440d3905f 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2739,7 +2739,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, // Initialize jump list const void *jump_iter = NULL; - cleanup_jumplist(curwin); + cleanup_jumplist(curwin, false); setpcmark(); do { xfmark_T fm; -- cgit From 854073f1dbdf6495a589a6d6794fc77d8dbe8741 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 08:44:57 -0400 Subject: vim-patch:8.1.0901: index in getjumplist() may be wrong Problem: Index in getjumplist() may be wrong. (Epheien) Solution: Call cleanup_jumplist() earlier. (Yegappan Lakshmanan, closes vim/vim#3941) https://github.com/vim/vim/commit/57ee2b6e0b5b730d12ee9db00a8e2a577df9e374 --- src/nvim/eval.c | 4 ++-- src/nvim/testdir/test_jumplist.vim | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a7b74b322f..6479163028 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10060,12 +10060,12 @@ static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } + cleanup_jumplist(wp, true); + list_T *const l = tv_list_alloc(wp->w_jumplistlen); tv_list_append_list(rettv->vval.v_list, l); tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx); - cleanup_jumplist(wp, true); - for (int i = 0; i < wp->w_jumplistlen; i++) { if (wp->w_jumplist[i].fmark.mark.lnum == 0) { continue; diff --git a/src/nvim/testdir/test_jumplist.vim b/src/nvim/testdir/test_jumplist.vim index 02dbd76194..be1af5e705 100644 --- a/src/nvim/testdir/test_jumplist.vim +++ b/src/nvim/testdir/test_jumplist.vim @@ -28,11 +28,13 @@ func Test_getjumplist() normal G normal gg - call assert_equal([[ + let expected = [[ \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, - \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4], - \ getjumplist()) + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 3] + call assert_equal(expected, getjumplist()) + " jumplist doesn't change in between calls + call assert_equal(expected, getjumplist()) " Traverse the jump list and verify the results 5 @@ -44,12 +46,14 @@ func Test_getjumplist() call assert_equal(3, getjumplist()[1]) exe "normal \" normal 20% - call assert_equal([[ + let expected = [[ \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0}, - \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 5], - \ getjumplist()) + \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4] + call assert_equal(expected, getjumplist()) + " jumplist doesn't change in between calls + call assert_equal(expected, getjumplist()) let l = getjumplist() call test_garbagecollect_now() -- cgit From bd885d878fdc33ac5dc1674d5977b4f96aae5507 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 08:57:10 -0400 Subject: lint --- src/nvim/mark.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 907cfe4833..5c9367ab01 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -782,7 +782,7 @@ void ex_jumps(exarg_T *eap) char_u *name; cleanup_jumplist(curwin, true); - /* Highlight title */ + // Highlight title MSG_PUTS_TITLE(_("\n jump line col file/text")); for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) { if (curwin->w_jumplist[i].fmark.mark.lnum != 0) { @@ -1161,7 +1161,6 @@ void mark_col_adjust( void cleanup_jumplist(win_T *wp, bool loadfiles) { int i; - int from, to; if (loadfiles) { // If specified, load all the files from the jump list. This is @@ -1175,17 +1174,20 @@ void cleanup_jumplist(win_T *wp, bool loadfiles) } } - to = 0; - for (from = 0; from < wp->w_jumplistlen; ++from) { - if (wp->w_jumplistidx == from) + int to = 0; + for (int from = 0; from < wp->w_jumplistlen; from++) { + if (wp->w_jumplistidx == from) { wp->w_jumplistidx = to; - for (i = from + 1; i < wp->w_jumplistlen; ++i) + } + for (i = from + 1; i < wp->w_jumplistlen; i++) { if (wp->w_jumplist[i].fmark.fnum == wp->w_jumplist[from].fmark.fnum && wp->w_jumplist[from].fmark.fnum != 0 && wp->w_jumplist[i].fmark.mark.lnum - == wp->w_jumplist[from].fmark.mark.lnum) + == wp->w_jumplist[from].fmark.mark.lnum) { break; + } + } if (i >= wp->w_jumplistlen) { // no duplicate if (to != from) { // Not using wp->w_jumplist[to++] = wp->w_jumplist[from] because -- cgit From 91c1737de67b0e3384fd69a6059b2c7b54690432 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 23:12:35 -0400 Subject: vim-patch:8.1.1357: test 37 is old style Problem: Test 37 is old style. Solution: Turn it into a new style test. (Yegappan Lakshmanan, closes vim/vim#4398) https://github.com/vim/vim/commit/999dc14644b8a9530ce0da22e90ca402c95c9c5a --- src/nvim/testdir/Makefile | 1 - src/nvim/testdir/test37.in | 116 ----------------- src/nvim/testdir/test37.ok | 33 ----- src/nvim/testdir/test_scrollbind.vim | 240 +++++++++++++++++++++++++++++++++++ 4 files changed, 240 insertions(+), 150 deletions(-) delete mode 100644 src/nvim/testdir/test37.in delete mode 100644 src/nvim/testdir/test37.ok (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 8ea2689939..7b1f0f59cc 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -14,7 +14,6 @@ export NVIM_PRG := $(NVIM_PRG) export TMPDIR := $(abspath ../../../Xtest-tmpdir) SCRIPTS_DEFAULT = \ - test37.out \ test42.out \ test48.out \ test52.out \ diff --git a/src/nvim/testdir/test37.in b/src/nvim/testdir/test37.in deleted file mode 100644 index 156bf74a10..0000000000 --- a/src/nvim/testdir/test37.in +++ /dev/null @@ -1,116 +0,0 @@ -Test for 'scrollbind'. Do not add a line below! -STARTTEST -: -:set noscrollbind -:set scrollopt=ver,jump -:set scrolloff=2 -:set nowrap -:set noequalalways -:set splitbelow -:" TEST using two windows open to one buffer, one extra empty window -:split -:new -t: -:resize 8 -/^start of window 1$/ -zt: -:set scrollbind -j: -:resize 7 -/^start of window 2$/ -zt: -:set scrollbind -:" -- start of tests -- -:" TEST scrolling down -L5jHyybpr0tHyybpr1tL6jHyybpr2kHyybpr3: -:" TEST scrolling up -tH4kjHtHyybpr4kHyybpr5k3ktHjHyybpr6tHyybpr7: -:" TEST horizontal scrolling -:set scrollopt+=hor -gg"zyyG"zpGt015zly$bp"zpGky$bp"zpG: -k10jH7zhg0y$bp"zpGtHg0y$bp"zpG: -:set scrollopt-=hor -:" ****** tests using two different buffers ***** -tj: -:close -t: -:set noscrollbind -:/^start of window 2$/,/^end of window 2$/y -:new -tj4"zpGp: -t/^start of window 1$/ -zt: -:set scrollbind -j: -/^start of window 2$/ -zt: -:set scrollbind -:" -- start of tests -- -:" TEST scrolling down -L5jHyybpr0tHyybpr1tL6jHyybpr2kHyybpr3: -:" TEST scrolling up -tH4kjHtHyybpr4kHyybpr5k3ktHjHyybpr6tHyybpr7: -:" TEST horizontal scrolling -:set scrollopt+=hor -gg"zyyG"zpGt015zly$bp"zpGky$bp"zpG: -k10jH7zhg0y$bp"zpGtHg0y$bp"zpG: -:set scrollopt-=hor -:" TEST syncbind -t:set noscb -ggLj:set noscb -ggL:set scb -t:set scb -GjG:syncbind -HktHjHyybptyybp: -t:set noscb -ggLj:set noscb -ggL:set scb -t:set scb -tGjGt:syncbind -HkjHtHyybptjyybp: -tH3kjHtHyybptjyybp: -:" ***** done with tests ***** -:w! test.out " Write contents of this file -:qa! -ENDTEST - - -start of window 1 -. line 01 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 01 -. line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02 -. line 03 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 03 -. line 04 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 04 -. line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05 -. line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06 -. line 07 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 07 -. line 08 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 08 -. line 09 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 09 -. line 10 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 10 -. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11 -. line 12 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 12 -. line 13 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 13 -. line 14 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 14 -. line 15 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 15 -end of window 1 - - -start of window 2 -. line 01 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 01 -. line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02 -. line 03 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 03 -. line 04 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 04 -. line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05 -. line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06 -. line 07 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 07 -. line 08 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 08 -. line 09 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 09 -. line 10 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 10 -. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11 -. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12 -. line 13 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 13 -. line 14 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 14 -. line 15 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 15 -. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16 -end of window 2 - -end of test37.in (please don't delete this line) diff --git a/src/nvim/testdir/test37.ok b/src/nvim/testdir/test37.ok deleted file mode 100644 index d0b74853b3..0000000000 --- a/src/nvim/testdir/test37.ok +++ /dev/null @@ -1,33 +0,0 @@ - -0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05 -1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05 -2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11 -3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11 -4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06 -5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06 -6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02 -7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02 -56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02 -UTSRQPONMLKJIHGREDCBA9876543210 02 -. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11 -. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11 - -0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05 -1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05 -2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11 -3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11 -4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06 -5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06 -6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02 -7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02 -56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02 -UTSRQPONMLKJIHGREDCBA9876543210 02 -. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11 -. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11 - -. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16 -:set scrollbind -:set scrollbind -. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16 -j: -. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12 diff --git a/src/nvim/testdir/test_scrollbind.vim b/src/nvim/testdir/test_scrollbind.vim index baa24f1979..6c5488be05 100644 --- a/src/nvim/testdir/test_scrollbind.vim +++ b/src/nvim/testdir/test_scrollbind.vim @@ -30,3 +30,243 @@ func Test_scrollbind() setl noscrollbind call assert_equal(0, topLineLeft - topLineRight) endfunc + +" Test for 'scrollbind' +func Test_scrollbind_opt() + new | only + set noscrollbind + set scrollopt=ver,jump scrolloff=2 nowrap noequalalways splitbelow + + " Insert the text used for the test + append + + +start of window 1 +. line 01 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 01 +. line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02 +. line 03 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 03 +. line 04 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 04 +. line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05 +. line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06 +. line 07 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 07 +. line 08 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 08 +. line 09 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 09 +. line 10 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 10 +. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11 +. line 12 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 12 +. line 13 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 13 +. line 14 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 14 +. line 15 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 15 +end of window 1 + + +start of window 2 +. line 01 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 01 +. line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02 +. line 03 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 03 +. line 04 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 04 +. line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05 +. line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06 +. line 07 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 07 +. line 08 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 08 +. line 09 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 09 +. line 10 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 10 +. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11 +. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12 +. line 13 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 13 +. line 14 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 14 +. line 15 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 15 +. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16 +end of window 2 + +. + + " Test using two windows open to one buffer, one extra empty window + split + new + wincmd t + resize 8 + call search('^start of window 1$') + normal zt + set scrollbind + wincmd j + resize 7 + call search('^start of window 2$') + normal zt + set scrollbind + + " -- start of tests -- + " Test scrolling down + normal L5jHyy + wincmd b | normal pr0 + wincmd t | normal Hyy + wincmd b | normal pr1 + wincmd t | normal L6jHyy + wincmd b | normal pr2 + wincmd k | normal Hyy + wincmd b | normal pr3 + + " Test scrolling up + wincmd t | normal H4k + wincmd j | normal H + wincmd t | normal Hyy + wincmd b | normal pr4 + wincmd k | normal Hyy + wincmd b | normal pr5 + wincmd k | normal 3k + wincmd t | normal H + wincmd j | normal Hyy + wincmd b | normal pr6 + wincmd t | normal Hyy + wincmd b | normal pr7 + + " Test horizontal scrolling + set scrollopt+=hor + normal gg"zyyG"zpG + wincmd t | normal 015zly$ + wincmd b | normal p"zpG + wincmd k | normal y$ + wincmd b | normal p"zpG + wincmd k | normal 10jH7zhg0y$ + wincmd b | normal p"zpG + wincmd t | normal Hg0y$ + wincmd b | normal p"zpG + set scrollopt-=hor + + wincmd b + call assert_equal([ + \ '', + \ '0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05', + \ '1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05', + \ '2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11', + \ '3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11', + \ '4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06', + \ '5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06', + \ '6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02', + \ '7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02', + \ '56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02', + \ 'UTSRQPONMLKJIHGREDCBA9876543210 02', + \ '. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11', + \ '. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11', + \ ''], getline(1, '$')) + enew! + + " ****** tests using two different buffers ***** + wincmd t | wincmd j | close + wincmd t | set noscrollbind + /start of window 2$/,/^end of window 2$/y + new + wincmd t | wincmd j | normal 4"zpGp + wincmd t + call search('^start of window 1$') + normal zt + set scrollbind + wincmd j + call search('^start of window 2$') + normal zt + set scrollbind + + " -- start of tests -- + " Test scrolling down + normal L5jHyy + wincmd b | normal pr0 + wincmd t | normal Hyy + wincmd b | normal pr1 + wincmd t | normal L6jHyy + wincmd b | normal pr2 + wincmd k | normal Hyy + wincmd b | normal pr3 + + " Test scrolling up + wincmd t | normal H4k + wincmd j | normal H + wincmd t | normal Hyy + wincmd b | normal pr4 + wincmd k | normal Hyy + wincmd b | normal pr5 + wincmd k | normal 3k + wincmd t | normal H + wincmd j | normal Hyy + wincmd b | normal pr6 + wincmd t | normal Hyy + wincmd b | normal pr7 + + " Test horizontal scrolling + set scrollopt+=hor + normal gg"zyyG"zpG + wincmd t | normal 015zly$ + wincmd b | normal p"zpG + wincmd k | normal y$ + wincmd b | normal p"zpG + wincmd k | normal 10jH7zhg0y$ + wincmd b | normal p"zpG + wincmd t | normal Hg0y$ + wincmd b | normal p"zpG + set scrollopt-=hor + + wincmd b + call assert_equal([ + \ '', + \ '0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05', + \ '1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05', + \ '2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11', + \ '3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11', + \ '4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06', + \ '5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06', + \ '6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02', + \ '7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02', + \ '56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02', + \ 'UTSRQPONMLKJIHGREDCBA9876543210 02', + \ '. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11', + \ '. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11', + \ ''], getline(1, '$')) + enew! + + " Test 'syncbind' + wincmd t | set noscrollbind | normal ggL + wincmd j | set noscrollbind | normal ggL + set scrollbind + wincmd t | set scrollbind | normal G + wincmd j | normal G + syncbind + normal Hk + wincmd t | normal H + wincmd j | normal Hyy + wincmd b | normal p + wincmd t | normal yy + wincmd b | normal p + wincmd t | set noscrollbind | normal ggL + wincmd j | set noscrollbind + normal ggL + set scrollbind + wincmd t | set scrollbind + wincmd t | normal G + wincmd j | normal G + wincmd t | syncbind | normal Hk + wincmd j | normal H + wincmd t | normal Hyy + wincmd b | normal p + wincmd t | wincmd j | normal yy + wincmd b | normal p + wincmd t | normal H3k + wincmd j | normal H + wincmd t | normal Hyy + wincmd b | normal p + wincmd t | wincmd j | normal yy + wincmd b | normal p + + wincmd b + call assert_equal([ + \ '', + \ '. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16', + \ 'start of window 2', + \ 'start of window 2', + \ '. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16', + \ '. line 15 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 15', + \ '. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12', + \ ], getline(1, '$')) + enew! + + new | only! + set scrollbind& scrollopt& scrolloff& wrap& equalalways& splitbelow& +endfunc -- cgit From 7ea350456d6b2f9c92f3dcf6feb7daa3e0abc079 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 19 May 2019 23:30:19 -0400 Subject: vim-patch:8.1.1358: cannot enter character with a CSI byte Problem: Cannot enter character with a CSI byte. Solution: Only check "gui.in_use" when VIMDLL is defined. (Ken Takata, closes vim/vim#4396) https://github.com/vim/vim/commit/386b43e59498cc7b52a60f09f74bdb44df99386c --- src/nvim/getchar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index f8c7dc613b..ec14803a2e 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1287,9 +1287,9 @@ openscript ( oldcurscript = curscript; do { - update_topline_cursor(); /* update cursor position and topline */ - normal_cmd(&oa, FALSE); /* execute one command */ - vpeekc(); /* check for end of file */ + update_topline_cursor(); // update cursor position and topline + normal_cmd(&oa, false); // execute one command + vpeekc(); // check for end of file } while (scriptin[oldcurscript] != NULL); State = save_State; -- cgit