diff options
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); |