# HG changeset patch # User Christian Brabandt # Date 1465849805 -7200 # Node ID 8000f0a44744fbfe14ab58c7d0e8fed031cfd7cd # Parent ddcef7b7874aaa00d967b99df8db9ea50f126bfe commit https://github.com/vim/vim/commit/ece74ab103eca15e17435efbe9cb21039787f1ea Author: Bram Moolenaar Date: Mon Jun 13 22:22:15 2016 +0200 patch 7.4.1932 Problem: When writing viminfo the jumplist is not merged with the one in the viminfo file. Solution: Merge based on timestamp. diff --git a/src/mark.c b/src/mark.c --- a/src/mark.c +++ b/src/mark.c @@ -1518,7 +1518,13 @@ handle_viminfo_mark(garray_T *values, in { for (idx = curwin->w_jumplistlen - 1; idx >= 0; --idx) if (curwin->w_jumplist[idx].time_set < timestamp) + { + ++idx; break; + } + if (idx < 0 && curwin->w_jumplistlen < JUMPLISTSIZE) + /* insert as the oldest entry */ + idx = 0; } else if (curwin->w_jumplistlen < JUMPLISTSIZE) /* insert as oldest entry */ @@ -1538,7 +1544,6 @@ handle_viminfo_mark(garray_T *values, in else { /* Move newer entries forward. */ - ++idx; for (i = curwin->w_jumplistlen; i > idx; --i) curwin->w_jumplist[i] = curwin->w_jumplist[i - 1]; ++curwin->w_jumplistidx; @@ -1684,10 +1689,23 @@ write_viminfo_filemarks(FILE *fp) fputs(_("\n# Jumplist (newest first):\n"), fp); setpcmark(); /* add current cursor position */ cleanup_jumplist(); - /* TODO: when vi_jumplist != NULL merge the two lists. */ - for (fm = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; - fm >= &curwin->w_jumplist[0]; --fm) + vi_idx = 0; + idx = curwin->w_jumplistlen - 1; + for (i = 0; i < JUMPLISTSIZE; ++i) { + xfmark_T *vi_fm; + + fm = idx >= 0 ? &curwin->w_jumplist[idx] : NULL; + vi_fm = vi_idx < vi_jumplist_len ? &vi_jumplist[vi_idx] : NULL; + if (fm == NULL && vi_fm == NULL) + break; + if (fm == NULL || (vi_fm != NULL && fm->time_set < vi_fm->time_set)) + { + fm = vi_fm; + ++vi_idx; + } + else + --idx; if (fm->fmark.fnum == 0 || ((buf = buflist_findnr(fm->fmark.fnum)) != NULL && !removable(buf->b_ffname))) diff --git a/src/testdir/test_viminfo.vim b/src/testdir/test_viminfo.vim --- a/src/testdir/test_viminfo.vim +++ b/src/testdir/test_viminfo.vim @@ -309,6 +309,33 @@ func Test_viminfo_jumplist() exe "normal \" call assert_equal('time 05', getline('.')) + clearjumps + call cursor(1, 1) + call test_settime(5) + exe "normal /15\r" + call test_settime(15) + exe "normal /last pos\r" + call test_settime(40) + exe "normal ?30\r" + " Test merge when writing + wviminfo Xviminfo + clearjumps + rviminfo Xviminfo + + exe "normal \" + call assert_equal('time 30', getline('.')) + exe "normal \" + call assert_equal('last pos', getline('.')) + exe "normal \" + " duplicate for 'time 30' was removed + call assert_equal('time 20', getline('.')) + exe "normal \" + call assert_equal('time 15', getline('.')) + exe "normal \" + call assert_equal('time 10', getline('.')) + exe "normal \" + call assert_equal('time 05', getline('.')) + bwipe! call delete('Xviminfo') endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1932, +/**/ 1931, /**/ 1930,