diff options
author | Abdelhakeem Osama <abdelhakeem.osama@hotmail.com> | 2019-04-02 00:50:28 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-02 00:50:28 +0200 |
commit | 35362495c965554f45634bcde3c4ce6d5eca52aa (patch) | |
tree | a5ab5056c94fec9e1585f33840b3c79a3209f204 /src | |
parent | a011f8a3211cfc3369437d8686c6999d491ba290 (diff) | |
download | rneovim-35362495c965554f45634bcde3c4ce6d5eca52aa.tar.gz rneovim-35362495c965554f45634bcde3c4ce6d5eca52aa.tar.bz2 rneovim-35362495c965554f45634bcde3c4ce6d5eca52aa.zip |
jumplist: avoid extra tail entry #9805
fixes #9775
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/mark.c | 16 | ||||
-rw-r--r-- | src/nvim/shada.c | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c index af404c354b..ecd1f098ca 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -1188,9 +1188,23 @@ void cleanup_jumplist(void) xfree(curwin->w_jumplist[from].fname); } } - if (curwin->w_jumplistidx == curwin->w_jumplistlen) + if (curwin->w_jumplistidx == curwin->w_jumplistlen) { curwin->w_jumplistidx = to; + } curwin->w_jumplistlen = to; + + // When pointer is below last jump, remove the jump if it matches the current + // line. This avoids useless/phantom jumps. #9805 + if (curwin->w_jumplistlen + && curwin->w_jumplistidx == curwin->w_jumplistlen) { + const xfmark_T *fm_last = &curwin->w_jumplist[curwin->w_jumplistlen - 1]; + if (fm_last->fmark.fnum == curbuf->b_fnum + && fm_last->fmark.mark.lnum == curwin->w_cursor.lnum) { + xfree(fm_last->fname); + curwin->w_jumplistlen--; + curwin->w_jumplistidx--; + } + } } /* diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 8864301e4c..658cd1ba46 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2739,8 +2739,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, // Initialize jump list const void *jump_iter = NULL; - setpcmark(); cleanup_jumplist(); + setpcmark(); do { xfmark_T fm; jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm); |