mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 06:46:07 +00:00
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user