aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/marktree.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-03-16 14:23:09 +0100
committerGitHub <noreply@github.com>2023-03-16 14:23:09 +0100
commit995196c614d14fa5947be4024fe8ea20c8a28973 (patch)
treecd4b6ed77b3f0cfc8ba57466d7a871920116f1d4 /src/nvim/marktree.c
parent320cb344c14b30f8c1aa8c2d86803e4c2f971ae9 (diff)
parent8021300806e2ccf04b3ec33970b682ee3c7a9cc3 (diff)
downloadrneovim-995196c614d14fa5947be4024fe8ea20c8a28973.tar.gz
rneovim-995196c614d14fa5947be4024fe8ea20c8a28973.tar.bz2
rneovim-995196c614d14fa5947be4024fe8ea20c8a28973.zip
Merge pull request #22687 from bfredl/intermarks
refactor(extmarks): some minor internal API changes
Diffstat (limited to 'src/nvim/marktree.c')
-rw-r--r--src/nvim/marktree.c14
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)