To: vim_dev@googlegroups.com Subject: Patch 8.0.1513 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1513 Problem: The jumplist is not always properly cleaned up. Solution: Call fname2fnum() before cleanup_jumplist(). (Yegappan Lakshmanan) Files: src/evalfunc.c, src/mark.c, src/proto/mark.pro *** ../vim-8.0.1512/src/evalfunc.c 2018-02-13 12:26:08.900247771 +0100 --- src/evalfunc.c 2018-02-13 13:27:21.178135044 +0100 *************** *** 4858,4870 **** return; list_append_number(rettv->vval.v_list, (varnumber_T)wp->w_jumplistidx); ! cleanup_jumplist(wp); for (i = 0; i < wp->w_jumplistlen; ++i) { if (wp->w_jumplist[i].fmark.mark.lnum == 0) continue; - if (wp->w_jumplist[i].fmark.fnum == 0) - fname2fnum(&wp->w_jumplist[i]); if ((d = dict_alloc()) == NULL) return; if (list_append_dict(l, d) == FAIL) --- 4858,4869 ---- 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) continue; if ((d = dict_alloc()) == NULL) return; if (list_append_dict(l, d) == FAIL) *** ../vim-8.0.1512/src/mark.c 2018-02-11 14:29:45.372349161 +0100 --- src/mark.c 2018-02-13 13:31:39.188316169 +0100 *************** *** 221,227 **** pos_T *pos; xfmark_T *jmp; ! cleanup_jumplist(curwin); if (curwin->w_jumplistlen == 0) /* nothing to jump to */ return (pos_T *)NULL; --- 221,227 ---- pos_T *pos; xfmark_T *jmp; ! cleanup_jumplist(curwin, TRUE); if (curwin->w_jumplistlen == 0) /* nothing to jump to */ return (pos_T *)NULL; *************** *** 891,897 **** int i; char_u *name; ! cleanup_jumplist(curwin); /* Highlight title */ MSG_PUTS_TITLE(_("\n jump line col file/text")); --- 891,897 ---- int i; char_u *name; ! cleanup_jumplist(curwin, TRUE); /* Highlight title */ MSG_PUTS_TITLE(_("\n jump line col file/text")); *************** *** 899,906 **** { if (curwin->w_jumplist[i].fmark.mark.lnum != 0) { - if (curwin->w_jumplist[i].fmark.fnum == 0) - fname2fnum(&curwin->w_jumplist[i]); name = fm_getname(&curwin->w_jumplist[i].fmark, 16); if (name == NULL) /* file name not available */ continue; --- 899,904 ---- *************** *** 1303,1315 **** /* * When deleting lines, this may create duplicate marks in the * jumplist. They will be removed here for the specified window. */ void ! cleanup_jumplist(win_T *wp) { int i; int from, to; to = 0; for (from = 0; from < wp->w_jumplistlen; ++from) { --- 1301,1328 ---- /* * When deleting lines, this may create duplicate marks in the * jumplist. They will be removed here for the specified window. + * When "loadfiles" is TRUE first ensure entries have the "fnum" field set + * (this may be a bit slow). */ void ! cleanup_jumplist(win_T *wp, int loadfiles) { int i; int from, to; + if (loadfiles) + { + /* If specified, load all the files from the jump list. This is + * needed to properly clean up duplicate entries, but will take some + * time. */ + for (i = 0; i < wp->w_jumplistlen; ++i) + { + if ((wp->w_jumplist[i].fmark.fnum == 0) && + (wp->w_jumplist[i].fmark.mark.lnum != 0)) + fname2fnum(&wp->w_jumplist[i]); + } + } + to = 0; for (from = 0; from < wp->w_jumplistlen; ++from) { *************** *** 1738,1744 **** /* Write the jumplist with -' */ fputs(_("\n# Jumplist (newest first):\n"), fp); setpcmark(); /* add current cursor position */ ! cleanup_jumplist(curwin); vi_idx = 0; idx = curwin->w_jumplistlen - 1; for (i = 0; i < JUMPLISTSIZE; ++i) --- 1751,1757 ---- /* Write the jumplist with -' */ fputs(_("\n# Jumplist (newest first):\n"), fp); setpcmark(); /* add current cursor position */ ! cleanup_jumplist(curwin, FALSE); vi_idx = 0; idx = curwin->w_jumplistlen - 1; for (i = 0; i < JUMPLISTSIZE; ++i) *** ../vim-8.0.1512/src/proto/mark.pro 2018-02-11 14:29:45.376349139 +0100 --- src/proto/mark.pro 2018-02-13 13:27:21.178135044 +0100 *************** *** 24,30 **** void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount); void copy_jumplist(win_T *from, win_T *to); void free_jumplist(win_T *wp); ! void cleanup_jumplist(win_T *wp); void set_last_cursor(win_T *win); void free_all_marks(void); int read_viminfo_filemark(vir_T *virp, int force); --- 24,30 ---- void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount); void copy_jumplist(win_T *from, win_T *to); void free_jumplist(win_T *wp); ! void cleanup_jumplist(win_T *wp, int loadfiles); void set_last_cursor(win_T *win); void free_all_marks(void); int read_viminfo_filemark(vir_T *virp, int force); *** ../vim-8.0.1512/src/version.c 2018-02-13 13:12:06.585200192 +0100 --- src/version.c 2018-02-13 13:28:45.573535153 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1513, /**/ -- MARTHA'S WAY: Don't throw out all that leftover wine. Freeze into ice cubes for future use in casseroles and sauces. MY WAY: What leftover wine? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///