neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 2137edbd4f15781a3a17091d38688a8ecbc02988
parent d9e6a442f2ff9aebf4d45ad6fb5b05d492eb4e38
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 22 Feb 2024 09:05:52 +0800

fix(extmarks): redraw properly with scoped inline virt_text (#27569)


Diffstat:
Msrc/nvim/api/extmark.c | 5+++--
Msrc/nvim/plines.c | 3++-
Mtest/functional/ui/decorations_spec.lua | 23+++++++++++++++++++++++
3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c @@ -26,6 +26,7 @@ #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" +#include "nvim/move.h" #include "nvim/pos_defs.h" #include "nvim/sign.h" @@ -1244,7 +1245,7 @@ Boolean nvim_win_add_ns(Window window, Integer ns_id, Error *err) set_put(uint32_t, &win->w_ns_set, (uint32_t)ns_id); - redraw_all_later(UPD_NOT_VALID); // TODO(altermo): only need to redraw the window + changed_window_setting_win(win); return true; } @@ -1289,7 +1290,7 @@ Boolean nvim_win_remove_ns(Window window, Integer ns_id, Error *err) set_del_uint32_t(&win->w_ns_set, (uint32_t)ns_id); - redraw_later(win, UPD_NOT_VALID); + changed_window_setting_win(win); return true; } diff --git a/src/nvim/plines.c b/src/nvim/plines.c @@ -153,7 +153,8 @@ CharSize charsize_regular(CharsizeArg *csarg, char *const cur, colnr_T const vco if (mark.pos.row != csarg->virt_row || mark.pos.col > col) { break; } else if (mark.pos.col == col) { - if (!mt_end(mark) && mark.flags & (MT_FLAG_DECOR_VIRT_TEXT_INLINE)) { + if (!mt_end(mark) && (mark.flags & MT_FLAG_DECOR_VIRT_TEXT_INLINE) + && mt_scoped_in_win(mark, wp)) { DecorInline decor = mt_decor(mark); DecorVirtText *vt = decor.ext ? decor.data.ext.vt : NULL; while (vt) { diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua @@ -5577,6 +5577,29 @@ describe('decorations: window scoped', function() screen:expect(noextmarks) end) + it('redraws correctly with inline virt_text and wrapping', function() + set_scoped_extmark(0, 2, { + virt_text = {{ ('b'):rep(18), 'Comment' }}, + virt_text_pos = 'inline' + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + 12{1:bbbbbbbbbbbbbbbbbb}| + 34^5 | + {2:~ }|*7 + | + ]]} + + api.nvim_win_remove_ns(0, ns) + + screen:expect(noextmarks) + end) + pending('sign_text', function() -- TODO(altermo): The window signcolumn width is calculated wrongly (when `signcolumn=auto`) -- This happens in function `win_redraw_signcols` on line containing `buf_meta_total(buf, kMTMetaSignText) > 0`