]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0422: popup: leave stray char when scrollbar changes v9.2.0422
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Fri, 1 May 2026 13:12:11 +0000 (13:12 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 1 May 2026 13:12:11 +0000 (13:12 +0000)
Problem:  popup: leave stray char when scrollbar changes
          (Maxim Kim, after v9.2.0112)
Solution: refresh popup mask when scrollbar visibility changes
          (Yasuhiro Matsumoto)

popup_adjust_position() set popup_mask_refresh only on geometry
changes, missing the case where w_has_scrollbar flips. After
popup_settext() shrinks the buffer enough that the scrollbar
disappears, the cell that held the old border / scrollbar was
never repainted, leaving stray characters.

fixes:  #20092
closes: #20098

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/popupwin.c
src/testdir/dumps/Test_popup_settext_scrollbar_disappear_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_popup_settext_scrollbar_disappear_2.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index f9208163388f659cfd2e2f41ab396ada1ca4afc2..103daccd29647363279778b27712d5ae3bf649cb 100644 (file)
@@ -1288,6 +1288,7 @@ popup_adjust_position(win_T *wp)
     int                org_height = wp->w_height;
     int                org_leftcol = wp->w_leftcol;
     int                org_leftoff = wp->w_popup_leftoff;
+    int                org_has_scrollbar = wp->w_has_scrollbar;
     int                minwidth, minheight;
     int                maxheight = Rows;
     int                wantline = wp->w_wantline;  // adjusted for textprop
@@ -1830,7 +1831,8 @@ popup_adjust_position(win_T *wp)
            || org_leftcol != wp->w_leftcol
            || org_leftoff != wp->w_popup_leftoff
            || org_width != wp->w_width
-           || org_height != wp->w_height)
+           || org_height != wp->w_height
+           || org_has_scrollbar != wp->w_has_scrollbar)
     {
        redraw_win_later(wp, UPD_NOT_VALID);
        if (wp->w_popup_flags & POPF_ON_CMDLINE)
diff --git a/src/testdir/dumps/Test_popup_settext_scrollbar_disappear_1.dump b/src/testdir/dumps/Test_popup_settext_scrollbar_disappear_1.dump
new file mode 100644 (file)
index 0000000..d11662f
--- /dev/null
@@ -0,0 +1,15 @@
+> +0&#ffffff0@49
+|~+0#4040ff13&| @48
+|~| @2|╔+0#0000001#ffd7ff255|═@30|╗| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|║+0#0000001#ffd7ff255|h|e|l@1|o| |w|o|r|l|d| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#4040ff13#ffffff0@12
+|~| @2|╚+0#0000001#ffd7ff255|═@30|╝| +0#4040ff13#ffffff0@12
+| +0#0000000&@31|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_popup_settext_scrollbar_disappear_2.dump b/src/testdir/dumps/Test_popup_settext_scrollbar_disappear_2.dump
new file mode 100644 (file)
index 0000000..52dc32b
--- /dev/null
@@ -0,0 +1,15 @@
+> +0&#ffffff0@49
+|~+0#4040ff13&| @48
+|~| @2|╔+0#0000001#ffd7ff255|═@29|╗| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255|s|h|o|r|t| @24|║| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|║+0#0000001#ffd7ff255| +0#4040ff13&@29|║+0#0000001&| +0#4040ff13#ffffff0@13
+|~| @2|╚+0#0000001#ffd7ff255|═@29|╝| +0#4040ff13#ffffff0@13
+|:+0#0000000&|c|a|l@1| |p|o|p|u|p|_|s|e|t@1|e|x|t|(|g|:|p|,| |[|'|s|h|o|r|t|0|,|0|-|1| @8|A|l@1| 
index 4ce6a7158a1e8158087a507d2b6fee3a6c8076b9..1bc9344df3e447f5df1590cb5843dd2659a9b343 100644 (file)
@@ -2563,6 +2563,32 @@ func Test_popup_settext()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_popup_settext_scrollbar_disappear()
+  CheckScreendump
+
+  let lines =<< trim END
+    let g:p = popup_create(repeat(['hello world'], 30), #{
+          \ line: 3,
+          \ col: 5,
+          \ pos: 'topleft',
+          \ minheight: 10,
+          \ maxheight: 10,
+          \ minwidth: 30,
+          \ border: [1, 1, 1, 1],
+          \ })
+  END
+  call writefile(lines, 'XtestPopupScrollDisappear', 'D')
+  let buf = RunVimInTerminal('-S XtestPopupScrollDisappear', #{rows: 15, cols: 50})
+  call VerifyScreenDump(buf, 'Test_popup_settext_scrollbar_disappear_1', {})
+
+  " Shrinking the buffer makes the scrollbar disappear.  The right border
+  " column must not leave stray characters where the scrollbar used to be.
+  call term_sendkeys(buf, ":call popup_settext(g:p, ['short'])\<CR>")
+  call VerifyScreenDump(buf, 'Test_popup_settext_scrollbar_disappear_2', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_popup_settext_getline()
   let id = popup_create('', #{ tabpage: 0 })
   call popup_settext(id, ['a','b'])
index 11ae9897aa49b4f3cffb28647da6439ad30bae1d..9a28bf20e13b4e58813c3ad805db6b29ea2e105c 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    422,
 /**/
     421,
 /**/