diff options
author | luukvbaal <luukvbaal@gmail.com> | 2025-01-15 11:38:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-15 02:38:45 -0800 |
commit | 5cc93ef4729c65d6a539c8d0a8a2bf767cf17ced (patch) | |
tree | 6aa1ecca4cf94db2f47f3d8285ee46514734afe9 | |
parent | 09bcb310681e3b87d5b8c5eb547b182554cff7b4 (diff) | |
download | rneovim-5cc93ef4729c65d6a539c8d0a8a2bf767cf17ced.tar.gz rneovim-5cc93ef4729c65d6a539c8d0a8a2bf767cf17ced.tar.bz2 rneovim-5cc93ef4729c65d6a539c8d0a8a2bf767cf17ced.zip |
fix(marks): revise metadata for start mark of revalidated pair #32017
Problem: Metadata may be revised for end mark of a revalidated pair.
Solution: Revise metadata for start mark of a revalidated pair.
-rw-r--r-- | src/nvim/extmark.c | 27 | ||||
-rw-r--r-- | test/functional/api/extmark_spec.lua | 2 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 5b47afa4b2..7e6dfb8dea 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -112,10 +112,10 @@ static void extmark_setraw(buf_T *buf, uint64_t mark, int row, colnr_T col, bool { MarkTreeIter itr[1] = { 0 }; MTKey key = marktree_lookup(buf->b_marktree, mark, itr); - bool move = key.pos.row >= 0 && (key.pos.row != row || key.pos.col != col); - // Already valid keys were being revalidated, presumably when encountering a - // SavePos from a modified mark. Avoid adding that to the decor again. - invalid = invalid && mt_invalid(key); + bool move = key.pos.row != row || key.pos.col != col; + if (key.pos.row < 0 || (!move && !invalid)) { + return; // Mark was deleted or no change needed + } // Only the position before undo needs to be redrawn here, // as the position after undo should be marked as changed. @@ -125,13 +125,16 @@ static void extmark_setraw(buf_T *buf, uint64_t mark, int row, colnr_T col, bool int row1 = 0; int row2 = 0; + MarkTreeIter altitr[1] = { *itr }; + MTKey alt = marktree_get_alt(buf->b_marktree, key, altitr); + if (invalid) { mt_itr_rawkey(itr).flags &= (uint16_t) ~MT_FLAG_INVALID; - marktree_revise_meta(buf->b_marktree, itr, key); - } else if (move && key.flags & MT_FLAG_DECOR_SIGNTEXT && buf->b_signcols.autom) { - MTPos end = marktree_get_altpos(buf->b_marktree, key, NULL); - row1 = MIN(end.row, MIN(key.pos.row, row)); - row2 = MAX(end.row, MAX(key.pos.row, row)); + mt_itr_rawkey(altitr).flags &= (uint16_t) ~MT_FLAG_INVALID; + marktree_revise_meta(buf->b_marktree, mt_end(key) ? altitr : itr, mt_end(key) ? alt : key); + } else if (!mt_invalid(key) && key.flags & MT_FLAG_DECOR_SIGNTEXT && buf->b_signcols.autom) { + row1 = MIN(alt.pos.row, MIN(key.pos.row, row)); + row2 = MAX(alt.pos.row, MAX(key.pos.row, row)); buf_signcols_count_range(buf, row1, row2, 0, kTrue); } @@ -140,10 +143,8 @@ static void extmark_setraw(buf_T *buf, uint64_t mark, int row, colnr_T col, bool } if (invalid) { - MTPos end = marktree_get_altpos(buf->b_marktree, key, itr); - mt_itr_rawkey(itr).flags &= (uint16_t) ~MT_FLAG_INVALID; - buf_put_decor(buf, mt_decor(key), row, end.row); - } else if (move && key.flags & MT_FLAG_DECOR_SIGNTEXT && buf->b_signcols.autom) { + buf_put_decor(buf, mt_decor(key), MIN(row, key.pos.row), MAX(row, key.pos.row)); + } else if (!mt_invalid(key) && key.flags & MT_FLAG_DECOR_SIGNTEXT && buf->b_signcols.autom) { buf_signcols_count_range(buf, row1, row2, 0, kNone); } } diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua index c8d6110207..8a4aea1efe 100644 --- a/test/functional/api/extmark_spec.lua +++ b/test/functional/api/extmark_spec.lua @@ -1794,7 +1794,7 @@ describe('API/extmarks', function() eq({}, get_extmark_by_id(ns, 4, {})) end) - it('no crash checking invalided flag of sign pair end key #31856', function() + it('no crash checking invalidated flag of sign pair end key #31856', function() api.nvim_buf_set_lines(0, 0, 1, false, { '', '' }) api.nvim_set_option_value('signcolumn', 'auto:2', {}) set_extmark(ns, 1, 0, 0, { sign_text = 'S1', invalidate = true, end_row = 0 }) |