aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/extmark.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2025-01-03 12:36:36 +0100
committerbfredl <bjorn.linse@gmail.com>2025-01-09 11:17:42 +0100
commit33ff546b50f759bd49d9518a94f8c2416848bdd7 (patch)
treead399dd3077e0a3078f922792322eee193dbd77d /src/nvim/extmark.c
parentfa298fd2f4b0c46df434938cbc17467e263cc094 (diff)
downloadrneovim-33ff546b50f759bd49d9518a94f8c2416848bdd7.tar.gz
rneovim-33ff546b50f759bd49d9518a94f8c2416848bdd7.tar.bz2
rneovim-33ff546b50f759bd49d9518a94f8c2416848bdd7.zip
fix(decoration): fix crash when on_lines decor provider modifies marktree
If a "on_lines" callback changes the structure of the marktree, the iterator (which is used for an entire window viewport) might now point to invalid memory. Restore the iterator to the beginning of the line in this case. fixes #29484
Diffstat (limited to 'src/nvim/extmark.c')
-rw-r--r--src/nvim/extmark.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index 6119d838f9..79eea718f4 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -95,6 +95,7 @@ void extmark_set(buf_T *buf, uint32_t ns_id, uint32_t *idp, int row, colnr_T col
MTKey mark = { { row, col }, ns_id, id, flags, decor.data };
marktree_put(buf->b_marktree, mark, end_row, end_col, end_right_gravity);
+ decor_state_invalidate(buf);
revised:
if (decor_flags || decor.ext) {
@@ -184,6 +185,8 @@ void extmark_del(buf_T *buf, MarkTreeIter *itr, MTKey key, bool restore)
}
}
+ decor_state_invalidate(buf);
+
// TODO(bfredl): delete it from current undo header, opportunistically?
}
@@ -237,6 +240,10 @@ bool extmark_clear(buf_T *buf, uint32_t ns_id, int l_row, colnr_T l_col, int u_r
}
}
+ if (marks_cleared_any) {
+ decor_state_invalidate(buf);
+ }
+
return marks_cleared_any;
}