diff options
Diffstat (limited to 'src/nvim/marktree.c')
-rw-r--r-- | src/nvim/marktree.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c index cb981bb00c..7e900bafa2 100644 --- a/src/nvim/marktree.c +++ b/src/nvim/marktree.c @@ -279,13 +279,13 @@ void marktree_put_key(MarkTree *b, mtkey_t k) /// 6. If 4 went all the way to the root node. The root node /// might have ended up with size 0. Delete it then. /// -/// NB: ideally keeps the iterator valid. Like point to the key after this -/// if present. +/// The iterator remains valid, and now points at the key _after_ the deleted +/// one. /// /// @param rev should be true if we plan to iterate _backwards_ and delete /// stuff before this key. Most of the time this is false (the /// recommended strategy is to always iterate forward) -void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) +uint64_t marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) { int adjustment = 0; @@ -294,6 +294,12 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) uint64_t id = mt_lookup_key(cur->key[curi]); // fprintf(stderr, "\nDELET %lu\n", id); + mtkey_t raw = rawkey(itr); + uint64_t other = 0; + if (mt_paired(raw)) { + other = mt_lookup_id(raw.ns, raw.id, !mt_end(raw)); + } + if (itr->node->level) { if (rev) { abort(); @@ -442,6 +448,8 @@ void marktree_del_itr(MarkTree *b, MarkTreeIter *itr, bool rev) marktree_itr_next(b, itr); } } + + return other; } static mtnode_t *merge_node(MarkTree *b, mtnode_t *p, int i) |