aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/extmark.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
commitff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch)
tree729bbcb92231538fa61dab6c3d890b025484b7f5 /src/nvim/extmark.c
parent376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff)
parent28c04948a1c887a1cc0cb64de79fa32631700466 (diff)
downloadrneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'src/nvim/extmark.c')
-rw-r--r--src/nvim/extmark.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index c4a34f8019..3236590010 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -206,7 +206,9 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r
}
}
- bool marks_cleared = false;
+ bool marks_cleared_any = false;
+ bool marks_cleared_all = l_row == 0 && l_col == 0;
+
MarkTreeIter itr[1] = { 0 };
marktree_itr_get(buf->b_marktree, l_row, l_col, itr);
while (true) {
@@ -214,16 +216,29 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r
if (mark.pos.row < 0
|| mark.pos.row > u_row
|| (mark.pos.row == u_row && mark.pos.col > u_col)) {
+ if (mark.pos.row >= 0) {
+ marks_cleared_all = false;
+ }
break;
}
if (mark.ns == ns_id || all_ns) {
- marks_cleared = true;
+ marks_cleared_any = true;
extmark_del(buf, itr, mark, true);
} else {
marktree_itr_next(buf->b_marktree, itr);
}
}
- return marks_cleared;
+
+ if (marks_cleared_all) {
+ if (all_ns) {
+ map_destroy(uint32_t, buf->b_extmark_ns);
+ *buf->b_extmark_ns = (Map(uint32_t, uint32_t)) MAP_INIT;
+ } else {
+ map_del(uint32_t, uint32_t)(buf->b_extmark_ns, ns_id, NULL);
+ }
+ }
+
+ return marks_cleared_any;
}
/// @return the position of marks between a range,
@@ -315,10 +330,6 @@ MTPair extmark_from_id(buf_T *buf, uint32_t ns_id, uint32_t id)
/// free extmarks from the buffer
void extmark_free_all(buf_T *buf)
{
- if (!map_size(buf->b_extmark_ns)) {
- return;
- }
-
MarkTreeIter itr[1] = { 0 };
marktree_itr_get(buf->b_marktree, 0, 0, itr);
while (true) {