aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/extmark.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/extmark.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/extmark.c')
-rw-r--r--src/nvim/extmark.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index 1132a5e752..d385a2018f 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -92,7 +92,7 @@ void extmark_set(buf_T *buf, uint32_t ns_id, uint32_t *idp, int row, colnr_T col
extmark_del(buf, ns_id, id);
} else {
// TODO(bfredl): we need to do more if "revising" a decoration mark.
- assert(itr->node);
+ assert(marktree_itr_valid(itr));
if (old_mark.pos.row == row && old_mark.pos.col == col) {
if (marktree_decor_level(old_mark) > kDecorLevelNone) {
decor_remove(buf, row, row, old_mark.decor_full);
@@ -191,12 +191,12 @@ bool extmark_del(buf_T *buf, uint32_t ns_id, uint32_t id)
return false;
}
assert(key.pos.row >= 0);
- marktree_del_itr(buf->b_marktree, itr, false);
+ uint64_t other = marktree_del_itr(buf->b_marktree, itr, false);
mtkey_t key2 = key;
- if (mt_paired(key)) {
- key2 = marktree_lookup_ns(buf->b_marktree, ns_id, id, true, itr);
+ if (other) {
+ key2 = marktree_lookup(buf->b_marktree, other, itr);
assert(key2.pos.row >= 0);
marktree_del_itr(buf->b_marktree, itr, false);
}
@@ -258,8 +258,11 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r
assert(mark.ns > 0 && mark.id > 0);
if (mark.ns == ns_id || all_ns) {
marks_cleared = true;
+ if (mark.decor_full && !mt_paired(mark)) { // if paired: deal with it later
+ decor_remove(buf, mark.pos.row, mark.pos.row, mark.decor_full);
+ }
+ uint64_t other = marktree_del_itr(buf->b_marktree, itr, false);
if (mt_paired(mark)) {
- uint64_t other = mt_lookup_id(mark.ns, mark.id, !mt_end(mark));
ssize_t decor_id = -1;
if (marktree_decor_level(mark) > kDecorLevelNone) {
// Save the decoration and the first pos. Clear the decoration
@@ -269,10 +272,7 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r
((DecorItem) { .row1 = mark.pos.row }));
}
map_put(uint64_t, ssize_t)(&delete_set, other, decor_id);
- } else if (mark.decor_full) {
- decor_remove(buf, mark.pos.row, mark.pos.row, mark.decor_full);
}
- marktree_del_itr(buf->b_marktree, itr, false);
} else {
marktree_itr_next(buf->b_marktree, itr);
}
@@ -281,7 +281,7 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r
ssize_t decor_id;
map_foreach(&delete_set, id, decor_id, {
mtkey_t mark = marktree_lookup(buf->b_marktree, id, itr);
- assert(itr->node);
+ assert(marktree_itr_valid(itr));
marktree_del_itr(buf->b_marktree, itr, false);
if (decor_id >= 0) {
DecorItem it = kv_A(decors, decor_id);
@@ -306,7 +306,7 @@ ExtmarkInfoArray extmark_get(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_co
ExtmarkInfoArray array = KV_INITIAL_VALUE;
MarkTreeIter itr[1];
// Find all the marks
- marktree_itr_get_ext(buf->b_marktree, (mtpos_t){ l_row, l_col },
+ marktree_itr_get_ext(buf->b_marktree, mtpos_t(l_row, l_col),
itr, reverse, false, NULL);
int order = reverse ? -1 : 1;
while ((int64_t)kv_size(array) < amount) {