aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/shada.c
diff options
context:
space:
mode:
authorAbdelhakeem Osama <abdelhakeem.osama@hotmail.com>2019-09-03 19:18:24 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-09-03 10:18:24 -0700
commit8b8ecf44f2cda43bbd710ec22ef99439b71888cd (patch)
treea98ade179a519f41f0445c436f7538896db0ef35 /src/nvim/shada.c
parentb8f2436febcc5d68e572d3703a21368e69ac1cb8 (diff)
downloadrneovim-8b8ecf44f2cda43bbd710ec22ef99439b71888cd.tar.gz
rneovim-8b8ecf44f2cda43bbd710ec22ef99439b71888cd.tar.bz2
rneovim-8b8ecf44f2cda43bbd710ec22ef99439b71888cd.zip
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.
Diffstat (limited to 'src/nvim/shada.c')
-rw-r--r--src/nvim/shada.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index 50f8990cf6..7e7e7cfdf7 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -2737,6 +2737,8 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
}
// Initialize jump list
+ setpcmark();
+ cleanup_jumplist(curwin, false);
wms->jumps_size = shada_init_jumps(wms->jumps, &removable_bufs);
// Initialize global marks
@@ -4086,11 +4088,13 @@ static bool shada_removable(const char *name)
static inline size_t shada_init_jumps(
PossiblyFreedShadaEntry *jumps, khash_t(bufset) *const removable_bufs)
{
- // Initialize jump list
+ if (!curwin->w_jumplistlen) {
+ return 0;
+ }
+
size_t jumps_size = 0;
const void *jump_iter = NULL;
- setpcmark();
- cleanup_jumplist(curwin, false);
+
do {
xfmark_T fm;
jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm);
@@ -4164,6 +4168,7 @@ void shada_encode_jumps(msgpack_sbuffer *const sbuf)
khash_t(bufset) removable_bufs = KHASH_EMPTY_TABLE(bufset);
find_removable_bufs(&removable_bufs);
PossiblyFreedShadaEntry jumps[JUMPLISTSIZE];
+ cleanup_jumplist(curwin, true);
size_t jumps_size = shada_init_jumps(jumps, &removable_bufs);
msgpack_packer packer;
msgpack_packer_init(&packer, sbuf, msgpack_sbuffer_write);