Skip to content

Commit 4867974

Browse files
committed
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)
1 parent e4db7ae commit 4867974

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/evalfunc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4858,13 +4858,12 @@ f_getjumplist(typval_T *argvars, typval_T *rettv)
48584858
return;
48594859
list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx);
48604860

4861-
cleanup_jumplist(wp);
4861+
cleanup_jumplist(wp, TRUE);
4862+
48624863
for (i = 0; i < wp->w_jumplistlen; ++i)
48634864
{
48644865
if (wp->w_jumplist[i].fmark.mark.lnum == 0)
48654866
continue;
4866-
if (wp->w_jumplist[i].fmark.fnum == 0)
4867-
fname2fnum(&wp->w_jumplist[i]);
48684867
if ((d = dict_alloc()) == NULL)
48694868
return;
48704869
if (list_append_dict(l, d) == FAIL)

src/mark.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ movemark(int count)
221221
pos_T *pos;
222222
xfmark_T *jmp;
223223

224-
cleanup_jumplist(curwin);
224+
cleanup_jumplist(curwin, TRUE);
225225

226226
if (curwin->w_jumplistlen == 0) /* nothing to jump to */
227227
return (pos_T *)NULL;
@@ -891,16 +891,14 @@ ex_jumps(exarg_T *eap UNUSED)
891891
int i;
892892
char_u *name;
893893

894-
cleanup_jumplist(curwin);
894+
cleanup_jumplist(curwin, TRUE);
895895

896896
/* Highlight title */
897897
MSG_PUTS_TITLE(_("\n jump line col file/text"));
898898
for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i)
899899
{
900900
if (curwin->w_jumplist[i].fmark.mark.lnum != 0)
901901
{
902-
if (curwin->w_jumplist[i].fmark.fnum == 0)
903-
fname2fnum(&curwin->w_jumplist[i]);
904902
name = fm_getname(&curwin->w_jumplist[i].fmark, 16);
905903
if (name == NULL) /* file name not available */
906904
continue;
@@ -1303,13 +1301,28 @@ mark_col_adjust(
13031301
/*
13041302
* When deleting lines, this may create duplicate marks in the
13051303
* jumplist. They will be removed here for the specified window.
1304+
* When "loadfiles" is TRUE first ensure entries have the "fnum" field set
1305+
* (this may be a bit slow).
13061306
*/
13071307
void
1308-
cleanup_jumplist(win_T *wp)
1308+
cleanup_jumplist(win_T *wp, int loadfiles)
13091309
{
13101310
int i;
13111311
int from, to;
13121312

1313+
if (loadfiles)
1314+
{
1315+
/* If specified, load all the files from the jump list. This is
1316+
* needed to properly clean up duplicate entries, but will take some
1317+
* time. */
1318+
for (i = 0; i < wp->w_jumplistlen; ++i)
1319+
{
1320+
if ((wp->w_jumplist[i].fmark.fnum == 0) &&
1321+
(wp->w_jumplist[i].fmark.mark.lnum != 0))
1322+
fname2fnum(&wp->w_jumplist[i]);
1323+
}
1324+
}
1325+
13131326
to = 0;
13141327
for (from = 0; from < wp->w_jumplistlen; ++from)
13151328
{
@@ -1738,7 +1751,7 @@ write_viminfo_filemarks(FILE *fp)
17381751
/* Write the jumplist with -' */
17391752
fputs(_("\n# Jumplist (newest first):\n"), fp);
17401753
setpcmark(); /* add current cursor position */
1741-
cleanup_jumplist(curwin);
1754+
cleanup_jumplist(curwin, FALSE);
17421755
vi_idx = 0;
17431756
idx = curwin->w_jumplistlen - 1;
17441757
for (i = 0; i < JUMPLISTSIZE; ++i)

src/proto/mark.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void mark_adjust_nofold(linenr_T line1, linenr_T line2, long amount, long amount
2424
void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount);
2525
void copy_jumplist(win_T *from, win_T *to);
2626
void free_jumplist(win_T *wp);
27-
void cleanup_jumplist(win_T *wp);
27+
void cleanup_jumplist(win_T *wp, int loadfiles);
2828
void set_last_cursor(win_T *win);
2929
void free_all_marks(void);
3030
int read_viminfo_filemark(vir_T *virp, int force);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1513,
774776
/**/
775777
1512,
776778
/**/

0 commit comments

Comments
 (0)