1
0
forked from aniani/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 #3941)
This commit is contained in:
Bram Moolenaar
2019-02-12 22:15:06 +01:00
parent 48773f1f83
commit 57ee2b6e0b
3 changed files with 14 additions and 8 deletions

View File

@@ -5271,6 +5271,8 @@ f_getjumplist(typval_T *argvars, typval_T *rettv)
if (wp == NULL) if (wp == NULL)
return; return;
cleanup_jumplist(wp, TRUE);
l = list_alloc(); l = list_alloc();
if (l == NULL) if (l == NULL)
return; return;
@@ -5279,8 +5281,6 @@ f_getjumplist(typval_T *argvars, typval_T *rettv)
return; return;
list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx); list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx);
cleanup_jumplist(wp, TRUE);
for (i = 0; i < wp->w_jumplistlen; ++i) for (i = 0; i < wp->w_jumplistlen; ++i)
{ {
if (wp->w_jumplist[i].fmark.mark.lnum == 0) if (wp->w_jumplist[i].fmark.mark.lnum == 0)

View File

@@ -28,11 +28,13 @@ func Test_getjumplist()
normal G normal G
normal gg normal gg
call assert_equal([[ let expected = [[
\ {'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': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4], \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 3]
\ getjumplist()) 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 " Traverse the jump list and verify the results
5 5
@@ -44,12 +46,14 @@ func Test_getjumplist()
call assert_equal(3, getjumplist()[1]) call assert_equal(3, getjumplist()[1])
exe "normal \<C-O>" exe "normal \<C-O>"
normal 20% normal 20%
call assert_equal([[ let expected = [[
\ {'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': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0}, \ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 5], \ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4]
\ getjumplist()) call assert_equal(expected, getjumplist())
" jumplist doesn't change in between calls
call assert_equal(expected, getjumplist())
let l = getjumplist() let l = getjumplist()
call test_garbagecollect_now() call test_garbagecollect_now()

View File

@@ -783,6 +783,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
901,
/**/ /**/
900, 900,
/**/ /**/