# HG changeset patch # User Bram Moolenaar # Date 1550007007 -3600 # Node ID c24572e66556dad3f634b0fbd11b2357978bd7d3 # Parent ecdf064c26a3eac5fc7aa2b4a7a253f665a09c88 patch 8.1.0901: index in getjumplist() may be wrong commit https://github.com/vim/vim/commit/57ee2b6e0b5b730d12ee9db00a8e2a577df9e374 Author: Bram Moolenaar Date: Tue Feb 12 22:15:06 2019 +0100 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 #3941) diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5271,6 +5271,8 @@ f_getjumplist(typval_T *argvars, typval_ if (wp == NULL) return; + cleanup_jumplist(wp, TRUE); + l = list_alloc(); if (l == NULL) return; @@ -5279,8 +5281,6 @@ f_getjumplist(typval_T *argvars, typval_ return; list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx); - cleanup_jumplist(wp, TRUE); - for (i = 0; i < wp->w_jumplistlen; ++i) { if (wp->w_jumplist[i].fmark.mark.lnum == 0) diff --git a/src/testdir/test_jumplist.vim b/src/testdir/test_jumplist.vim --- a/src/testdir/test_jumplist.vim +++ b/src/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() diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -784,6 +784,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 901, +/**/ 900, /**/ 899,