mirror of
https://github.com/neovim/neovim.git
synced 2025-09-15 07:48:18 +00:00
shada/context: fully remove jumplist duplicates #10898
- Always load files when cleaning up jumplist. - For Shada: avoids writing duplicate entries, which happens when you read from a shada file with duplicate entries (merging the jumplist while writing sometimes produces duplicate entries, bug?) and then write right away (i.e.: without any `:jumps`, `getjumplist()`, or any jump movement, that is: nothing that calls `cleanup_jumplist` with `loadfiles == true`). - For Context: avoids non-idempotent behavior for the same reason (i.e.: first call to `shada_encode_jumps` does not remove duplicate entries). - Do not set pcmark when dumping jumplist for Context. - Retrieving current Context shouldn't add an entry to the jumplist (which will be removed by a subsequent `cleanup_jumplist` anyway, i.e.: tail entry matching current position), just act like `getjumplist` for instance.
This commit is contained in:

committed by
Justin M. Keyes

parent
b8f2436feb
commit
8b8ecf44f2
@@ -1162,21 +1162,18 @@ void mark_col_adjust(
|
||||
|
||||
// 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, bool loadfiles)
|
||||
// When "checktail" is true, removes tail jump if it matches current position.
|
||||
void cleanup_jumplist(win_T *wp, bool checktail)
|
||||
{
|
||||
int i;
|
||||
|
||||
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]);
|
||||
}
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1213,8 +1210,8 @@ void cleanup_jumplist(win_T *wp, bool loadfiles)
|
||||
|
||||
// When pointer is below last jump, remove the jump if it matches the current
|
||||
// line. This avoids useless/phantom jumps. #9805
|
||||
if (loadfiles // otherwise (i.e.: Shada), last entry should be kept
|
||||
&& wp->w_jumplistlen && wp->w_jumplistidx == wp->w_jumplistlen) {
|
||||
if (checktail && wp->w_jumplistlen
|
||||
&& wp->w_jumplistidx == wp->w_jumplistlen) {
|
||||
const xfmark_T *fm_last = &wp->w_jumplist[wp->w_jumplistlen - 1];
|
||||
if (fm_last->fmark.fnum == curbuf->b_fnum
|
||||
&& fm_last->fmark.mark.lnum == wp->w_cursor.lnum) {
|
||||
|
Reference in New Issue
Block a user