summaryrefslogtreecommitdiff
path: root/src/mark.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-02-11 14:29:49 +0100
committerBram Moolenaar <Bram@vim.org>2018-02-11 14:29:49 +0100
commita7e18d237f817637815f0de44b08df1e0ca0f4f9 (patch)
treecad88062207343bb09054f95c80b327809d0d8a7 /src/mark.c
parent4f50588ba336e7f086a72c53f5688c2494fc34b3 (diff)
downloadvim-git-a7e18d237f817637815f0de44b08df1e0ca0f4f9.tar.gz
patch 8.0.1498: getjumplist() returns duplicate entriesv8.0.1498
Problem: Getjumplist() returns duplicate entries. (lacygoill) Solution: Call cleanup_jumplist(). (Yegappan Lakshmanan)
Diffstat (limited to 'src/mark.c')
-rw-r--r--src/mark.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/src/mark.c b/src/mark.c
index 1acdd12d6..9ebc9c24c 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -27,13 +27,9 @@
#define EXTRA_MARKS 10 /* marks 0-9 */
static xfmark_T namedfm[NMARKS + EXTRA_MARKS]; /* marks with file nr */
-static void fname2fnum(xfmark_T *fm);
static void fmarks_check_one(xfmark_T *fm, char_u *name, buf_T *buf);
static char_u *mark_line(pos_T *mp, int lead_len);
static void show_one_mark(int, char_u *, pos_T *, char_u *, int current);
-#ifdef FEAT_JUMPLIST
-static void cleanup_jumplist(void);
-#endif
#ifdef FEAT_VIMINFO
static void write_one_filemark(FILE *fp, xfmark_T *fm, int c1, int c2);
#endif
@@ -225,7 +221,7 @@ movemark(int count)
pos_T *pos;
xfmark_T *jmp;
- cleanup_jumplist();
+ cleanup_jumplist(curwin);
if (curwin->w_jumplistlen == 0) /* nothing to jump to */
return (pos_T *)NULL;
@@ -519,7 +515,7 @@ getnextmark(
* This is used for marks obtained from the .viminfo file. It's postponed
* until the mark is used to avoid a long startup delay.
*/
- static void
+ void
fname2fnum(xfmark_T *fm)
{
char_u *p;
@@ -895,7 +891,8 @@ ex_jumps(exarg_T *eap UNUSED)
int i;
char_u *name;
- cleanup_jumplist();
+ cleanup_jumplist(curwin);
+
/* Highlight title */
MSG_PUTS_TITLE(_("\n jump line col file/text"));
for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i)
@@ -1305,34 +1302,34 @@ mark_col_adjust(
#ifdef FEAT_JUMPLIST
/*
* When deleting lines, this may create duplicate marks in the
- * jumplist. They will be removed here for the current window.
+ * jumplist. They will be removed here for the specified window.
*/
- static void
-cleanup_jumplist(void)
+ void
+cleanup_jumplist(win_T *wp)
{
int i;
int from, to;
to = 0;
- for (from = 0; from < curwin->w_jumplistlen; ++from)
+ for (from = 0; from < wp->w_jumplistlen; ++from)
{
- if (curwin->w_jumplistidx == from)
- curwin->w_jumplistidx = to;
- for (i = from + 1; i < curwin->w_jumplistlen; ++i)
- if (curwin->w_jumplist[i].fmark.fnum
- == curwin->w_jumplist[from].fmark.fnum
- && curwin->w_jumplist[from].fmark.fnum != 0
- && curwin->w_jumplist[i].fmark.mark.lnum
- == curwin->w_jumplist[from].fmark.mark.lnum)
+ if (wp->w_jumplistidx == from)
+ wp->w_jumplistidx = to;
+ for (i = from + 1; i < wp->w_jumplistlen; ++i)
+ if (wp->w_jumplist[i].fmark.fnum
+ == wp->w_jumplist[from].fmark.fnum
+ && wp->w_jumplist[from].fmark.fnum != 0
+ && wp->w_jumplist[i].fmark.mark.lnum
+ == wp->w_jumplist[from].fmark.mark.lnum)
break;
- if (i >= curwin->w_jumplistlen) /* no duplicate */
- curwin->w_jumplist[to++] = curwin->w_jumplist[from];
+ if (i >= wp->w_jumplistlen) /* no duplicate */
+ wp->w_jumplist[to++] = wp->w_jumplist[from];
else
- vim_free(curwin->w_jumplist[from].fname);
+ vim_free(wp->w_jumplist[from].fname);
}
- if (curwin->w_jumplistidx == curwin->w_jumplistlen)
- curwin->w_jumplistidx = to;
- curwin->w_jumplistlen = to;
+ if (wp->w_jumplistidx == wp->w_jumplistlen)
+ wp->w_jumplistidx = to;
+ wp->w_jumplistlen = to;
}
/*
@@ -1741,7 +1738,7 @@ write_viminfo_filemarks(FILE *fp)
/* Write the jumplist with -' */
fputs(_("\n# Jumplist (newest first):\n"), fp);
setpcmark(); /* add current cursor position */
- cleanup_jumplist();
+ cleanup_jumplist(curwin);
vi_idx = 0;
idx = curwin->w_jumplistlen - 1;
for (i = 0; i < JUMPLISTSIZE; ++i)