fix(marks): issues with invalid marks and marks beyond eob (#32862)

Problem:  Marks that go beyond the end of the buffer, and paired marks
          whose end is in front of its start mark are added to and
          removed from the decor. This results in incorrect tracking
          of the signcolumn.
Solution: Ensure such marks are not added to and removed from the decor.
This commit is contained in:
luukvbaal
2025-03-16 12:15:50 +01:00
committed by GitHub
parent 466f20dd70
commit 72f630f92d
4 changed files with 41 additions and 11 deletions

View File

@@ -182,8 +182,9 @@ DecorSignHighlight decor_sh_from_inline(DecorHighlightInline item)
void buf_put_decor(buf_T *buf, DecorInline decor, int row, int row2)
{
if (decor.ext) {
if (decor.ext && row < buf->b_ml.ml_line_count) {
uint32_t idx = decor.data.ext.sh_idx;
row2 = MIN(buf->b_ml.ml_line_count - 1, row2);
while (idx != DECOR_ID_INVALID) {
DecorSignHighlight *sh = &kv_A(decor_items, idx);
buf_put_decor_sh(buf, sh, row, row2);
@@ -222,16 +223,17 @@ void buf_put_decor_sh(buf_T *buf, DecorSignHighlight *sh, int row1, int row2)
void buf_decor_remove(buf_T *buf, int row1, int row2, int col1, DecorInline decor, bool free)
{
decor_redraw(buf, row1, row2, col1, decor);
if (decor.ext) {
if (decor.ext && row1 < buf->b_ml.ml_line_count) {
uint32_t idx = decor.data.ext.sh_idx;
row2 = MIN(buf->b_ml.ml_line_count - 1, row2);
while (idx != DECOR_ID_INVALID) {
DecorSignHighlight *sh = &kv_A(decor_items, idx);
buf_remove_decor_sh(buf, row1, row2, sh);
idx = sh->next;
}
if (free) {
decor_free(decor);
}
}
if (free) {
decor_free(decor);
}
}