mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 11:26:37 +00:00
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)
57ee2b6e0b
This commit is contained in:
@@ -10060,12 +10060,12 @@ static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup_jumplist(wp, true);
|
||||||
|
|
||||||
list_T *const l = tv_list_alloc(wp->w_jumplistlen);
|
list_T *const l = tv_list_alloc(wp->w_jumplistlen);
|
||||||
tv_list_append_list(rettv->vval.v_list, l);
|
tv_list_append_list(rettv->vval.v_list, l);
|
||||||
tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx);
|
tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx);
|
||||||
|
|
||||||
cleanup_jumplist(wp, true);
|
|
||||||
|
|
||||||
for (int i = 0; i < wp->w_jumplistlen; i++) {
|
for (int 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) {
|
||||||
continue;
|
continue;
|
||||||
|
@@ -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()
|
||||||
|
Reference in New Issue
Block a user