From 28698bca20dd3970cd7a7e2996ecc74ce00f151b Mon Sep 17 00:00:00 2001 From: Hirohito Higashi Date: Mon, 3 Aug 2026 20:38:42 +0000 Subject: [PATCH] patch 9.2.0907: popup: virtual text is not redrawn when a text property changes Problem: Adding or removing a text property in the buffer of a popup window does not update the popup on the screen. The old virtual text stays visible until something else causes a redraw. Solution: Also mark popup windows displaying the buffer for redrawing in redraw_buf_later() (Hirohito Higashi). fixes: #19297 closes: #20931 Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- src/drawscreen.c | 9 +++++ .../Test_popupwin_textprop_redraw_1.dump | 10 +++++ .../Test_popupwin_textprop_redraw_2.dump | 10 +++++ src/testdir/test_popupwin.vim | 37 +++++++++++++++++++ src/version.c | 2 + 5 files changed, 68 insertions(+) create mode 100644 src/testdir/dumps/Test_popupwin_textprop_redraw_1.dump create mode 100644 src/testdir/dumps/Test_popupwin_textprop_redraw_2.dump diff --git a/src/drawscreen.c b/src/drawscreen.c index f5271e7c17..d85ae57dce 100644 --- a/src/drawscreen.c +++ b/src/drawscreen.c @@ -3443,6 +3443,15 @@ redraw_buf_later(buf_T *buf, int type) if (wp->w_buffer == buf) redraw_win_later(wp, type); } +#ifdef FEAT_PROP_POPUP + // popup windows are not in the list of windows + FOR_ALL_POPUPWINS(wp) + if (wp->w_buffer == buf) + redraw_win_later(wp, type); + FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) + if (wp->w_buffer == buf) + redraw_win_later(wp, type); +#endif #if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP) // terminal in popup window is not in list of windows if (curwin->w_buffer == buf) diff --git a/src/testdir/dumps/Test_popupwin_textprop_redraw_1.dump b/src/testdir/dumps/Test_popupwin_textprop_redraw_1.dump new file mode 100644 index 0000000000..27326b4ee4 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_textprop_redraw_1.dump @@ -0,0 +1,10 @@ +> +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| |╔+0#0000001#ffd7ff255|═@29|╗| +0#4040ff13#ffffff0@40 +|~| |║+0#0000001#ffd7ff255|p|o|p|u|p| |t|e|x|t| @11|c+0&#ffff4012|o|u|n|t|=|1| |║+0&#ffd7ff255| +0#4040ff13#ffffff0@40 +|~| |╚+0#0000001#ffd7ff255|═@29|╝| +0#4040ff13#ffffff0@40 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|"+0#0000000&|X|p|o|p|u|p|P|r|o|p|"| |[|N|e|w|]| @38|0|,|0|-|1| @8|A|l@1| diff --git a/src/testdir/dumps/Test_popupwin_textprop_redraw_2.dump b/src/testdir/dumps/Test_popupwin_textprop_redraw_2.dump new file mode 100644 index 0000000000..f713073d63 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_textprop_redraw_2.dump @@ -0,0 +1,10 @@ +> +0&#ffffff0@74 +|~+0#4040ff13&| @73 +|~| |╔+0#0000001#ffd7ff255|═@29|╗| +0#4040ff13#ffffff0@40 +|~| |║+0#0000001#ffd7ff255|p|o|p|u|p| |t|e|x|t| @11|c+0&#ffff4012|o|u|n|t|=|2| |║+0&#ffd7ff255| +0#4040ff13#ffffff0@40 +|~| |╚+0#0000001#ffd7ff255|═@29|╝| +0#4040ff13#ffffff0@40 +|~| @73 +|~| @73 +|~| @73 +|~| @73 +|"+0#0000000&|X|p|o|p|u|p|P|r|o|p|"| |[|N|e|w|]| @38|0|,|0|-|1| @8|A|l@1| diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 2663c52da2..6826731090 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -6243,4 +6243,41 @@ func Test_popup_image_clipwindow_scroll() call prop_type_delete('imgclipprop') endfunc +func Test_popupwin_textprop_redraw() + CheckScreendump + + let lines =<< trim END + vim9script + var buf = bufadd('XpopupProp') + bufload(buf) + setbufline(buf, 1, 'popup text') + prop_type_add('counter', {bufnr: buf, highlight: 'Search'}) + popup_create(buf, {line: 3, col: 3, minwidth: 30, border: []}) + + var counter = 0 + def g:UpdateProp() + counter += 1 + prop_remove({all: true, type: 'counter', bufnr: buf}, 1) + prop_add(1, 0, { + bufnr: buf, + type: 'counter', + text: $'count={counter} ', + text_align: 'right', + }) + enddef + nnoremap g:UpdateProp() + END + call writefile(lines, 'XtestPopupProp', 'D') + let buf = RunVimInTerminal('-S XtestPopupProp', #{rows: 10}) + + " Updating only the virtual text of the popup buffer must redraw the popup. + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_popupwin_textprop_redraw_1', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_popupwin_textprop_redraw_2', {}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 diff --git a/src/version.c b/src/version.c index 13c9fc7d31..5a748f4996 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 907, /**/ 906, /**/ -- 2.47.3