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

This commit is contained in:
zeertzjq 2024-02-22 09:05:52 +08:00 committed by GitHub
parent d9e6a442f2
commit 2137edbd4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 3 deletions

View File

@ -26,6 +26,7 @@
#include "nvim/mbyte.h" #include "nvim/mbyte.h"
#include "nvim/memline.h" #include "nvim/memline.h"
#include "nvim/memory.h" #include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/pos_defs.h" #include "nvim/pos_defs.h"
#include "nvim/sign.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); 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; 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); 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; return true;
} }

View File

@ -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) { if (mark.pos.row != csarg->virt_row || mark.pos.col > col) {
break; break;
} else if (mark.pos.col == col) { } 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); DecorInline decor = mt_decor(mark);
DecorVirtText *vt = decor.ext ? decor.data.ext.vt : NULL; DecorVirtText *vt = decor.ext ? decor.data.ext.vt : NULL;
while (vt) { while (vt) {

View File

@ -5577,6 +5577,29 @@ describe('decorations: window scoped', function()
screen:expect(noextmarks) screen:expect(noextmarks)
end) 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() pending('sign_text', function()
-- TODO(altermo): The window signcolumn width is calculated wrongly (when `signcolumn=auto`) -- 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` -- This happens in function `win_redraw_signcols` on line containing `buf_meta_total(buf, kMTMetaSignText) > 0`