]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0094: popup: concealed text causes incorrect truncation v9.2.0094
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Mon, 2 Mar 2026 19:45:11 +0000 (19:45 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 2 Mar 2026 19:45:11 +0000 (19:45 +0000)
Problem:  In popup windows, concealed characters and tab expansion
          may cause wrong truncation for fixed width windows.
Solution: Do not adjust the screen column and bogus column counters
          for popup windows when handling concealed text or extra
          padding characters (Yasuhiro Matsumoto).

closes: #19121

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

index 4597d8d3cae7acf1057a6de45a84f4c117434671..8880cb9a83c723a106ea9353c025b6490133fe8c 100644 (file)
@@ -4182,20 +4182,34 @@ win_line(
                // trailing junk to be written out of the screen line
                // we are building, 'boguscols' keeps track of the number
                // of bad columns we have advanced.
+               //
+               // For popup windows with fixed width, don't advance col
+               // to allow full text to be displayed.
+# ifdef FEAT_PROP_POPUP
+               int adjust_col = !WIN_IS_POPUP(wp);
+# else
+               int adjust_col = TRUE;
+# endif
                if (wlv.n_extra > 0)
                {
                    wlv.vcol += wlv.n_extra;
 # ifdef FEAT_RIGHTLEFT
                    if (wp->w_p_rl)
                    {
-                       wlv.col -= wlv.n_extra;
-                       wlv.boguscols -= wlv.n_extra;
+                       if (adjust_col)
+                       {
+                           wlv.col -= wlv.n_extra;
+                           wlv.boguscols -= wlv.n_extra;
+                       }
                    }
                    else
 # endif
                    {
-                       wlv.col += wlv.n_extra;
-                       wlv.boguscols += wlv.n_extra;
+                       if (adjust_col)
+                       {
+                           wlv.col += wlv.n_extra;
+                           wlv.boguscols += wlv.n_extra;
+                       }
                    }
                    wlv.n_extra = 0;
                    n_attr = 0;
@@ -4207,28 +4221,40 @@ win_line(
 # ifdef FEAT_RIGHTLEFT
                    if (wp->w_p_rl)
                    {
-                       --wlv.boguscols;
-                       --wlv.col;
+                       if (adjust_col)
+                       {
+                           --wlv.boguscols;
+                           --wlv.col;
+                       }
                    }
                    else
 # endif
                    {
-                       ++wlv.boguscols;
-                       ++wlv.col;
+                       if (adjust_col)
+                       {
+                           ++wlv.boguscols;
+                           ++wlv.col;
+                       }
                    }
                }
 
 # ifdef FEAT_RIGHTLEFT
                if (wp->w_p_rl)
                {
-                   --wlv.boguscols;
-                   --wlv.col;
+                   if (adjust_col)
+                   {
+                       --wlv.boguscols;
+                       --wlv.col;
+                   }
                }
                else
 # endif
                {
-                   ++wlv.boguscols;
-                   ++wlv.col;
+                   if (adjust_col)
+                   {
+                       ++wlv.boguscols;
+                       ++wlv.col;
+                   }
                }
            }
            else
diff --git a/src/testdir/dumps/Test_popupwin_conceal_01.dump b/src/testdir/dumps/Test_popupwin_conceal_01.dump
new file mode 100644 (file)
index 0000000..a5e92fa
--- /dev/null
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @7|╔+0#0000001#ffd7ff255|═@39|╗| +0#0000000#ffffff0@23
+|4| @7|║+0#0000001#ffd7ff255|H|e|r|e| |i|s| |a| @1|w|o|r|d| |t|h|a|t| |w|i|l@1| |b|e| |h|i|d@1|e|n|.| @3|║| +0#0000000#ffffff0@23
+|5| @7|║+0#0000001#ffd7ff255| +0#4040ff13&@39|║+0#0000001&| +0#0000000#ffffff0@23
+|6| @7|╚+0#0000001#ffd7ff255|═@39|╝| +0#0000000#ffffff0@23
+|7| @73
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_popupwin_conceal_02.dump b/src/testdir/dumps/Test_popupwin_conceal_02.dump
new file mode 100644 (file)
index 0000000..dfa2409
--- /dev/null
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @7|╔+0#0000001#ffd7ff255|═@39|╗| +0#0000000#ffffff0@23
+|4| @7|║+0#0000001#ffd7ff255|H|e|r|e| |i|s| |a| @1|w|o|r|d| |t|h|a|t| |w|i|l@1| |b|e| |h|i|d@1|e|n|.| |A|n|d|║| +0#0000000#ffffff0@23
+|5| @7|║+0#0000001#ffd7ff255| |m|o|r|e| |t|e|x|t| |h|e|r|e|.| @23|║| +0#0000000#ffffff0@23
+|6| @7|╚+0#0000001#ffd7ff255|═@39|╝| +0#0000000#ffffff0@23
+|7| @73
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_popupwin_conceal_03.dump b/src/testdir/dumps/Test_popupwin_conceal_03.dump
new file mode 100644 (file)
index 0000000..d2e1b2f
--- /dev/null
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|3| @7|╔+0#0000001#ffd7ff255|═@39|╗| +0#0000000#ffffff0@23
+|4| @7|║+0#0000001#ffd7ff255|H|e|r|e|>+0#0000e05&|-@2|i+0#0000001&|s|>+0#0000e05&|-@4|a+0#0000001&| @1|w|o|r|d|>+0#0000e05&|-@7|w+0#0000001&|i|t|h|>+0#0000e05&|-@2|║+0#0000001&| +0#0000000#ffffff0@23
+|5| @7|║+0#0000001#ffd7ff255|t|a|b|s|.| @34|║| +0#0000000#ffffff0@23
+|6| @7|╚+0#0000001#ffd7ff255|═@39|╝| +0#0000000#ffffff0@23
+|7| @73
+|8| @73
+|9| @73
+@57|1|,|1| @10|T|o|p| 
index 5f87f34e15470590c28d3ee487646e19b4198eb1..a2626a637df76b59c97839e8e2eecb36bd41958d 100644 (file)
@@ -4899,4 +4899,54 @@ func Test_popup_opacity_wide_char_overlap()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_popup_conceal_wrap()
+  CheckFeature conceal
+  CheckScreendump
+
+  " Test that concealed text in popup windows doesn't cause truncation
+  let lines =<< trim END
+    call setline(1, range(1, 20))
+
+    " Create popup with concealed text
+    let text = "Here is a SECRET word that will be hidden."
+    let winid = popup_create([text], #{
+          \ line: 3,
+          \ col: 10,
+          \ minwidth: 40,
+          \ maxwidth: 40,
+          \ border: [],
+          \ wrap: 1,
+          \ })
+
+    " Set up conceal
+    call win_execute(winid, 'setlocal conceallevel=2')
+    call win_execute(winid, 'setlocal concealcursor=nvic')
+    call win_execute(winid, 'syntax match HiddenSecret /SECRET/ conceal containedin=ALL')
+  END
+  call writefile(lines, 'XtestPopupConceal', 'D')
+  let buf = RunVimInTerminal('-S XtestPopupConceal', #{rows: 10})
+  call VerifyScreenDump(buf, 'Test_popupwin_conceal_01', {})
+
+  " Test with longer text that wraps
+  call term_sendkeys(buf, ":call popup_close(winid)\<CR>")
+  call term_sendkeys(buf, ":let text2 = 'Here is a SECRET word that will be hidden. And more text here.'\<CR>")
+  call term_sendkeys(buf, ":let winid2 = popup_create([text2], #{line: 3, col: 10, minwidth: 40, maxwidth: 40, border: [], wrap: 1})\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid2, 'setlocal conceallevel=2')\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid2, 'setlocal concealcursor=nvic')\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid2, 'syntax match HiddenSecret /SECRET/ conceal containedin=ALL')\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_conceal_02', {})
+
+  " Test with TAB characters (uses n_extra)
+  call term_sendkeys(buf, ":call popup_close(winid2)\<CR>")
+  call term_sendkeys(buf, ":let text3 = \"Here\\tis\\ta SECRET word\\twith\\ttabs.\"\<CR>")
+  call term_sendkeys(buf, ":let winid3 = popup_create([text3], #{line: 3, col: 10, minwidth: 40, maxwidth: 40, border: [], wrap: 1})\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid3, 'setlocal conceallevel=2')\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid3, 'setlocal concealcursor=nvic')\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid3, 'setlocal list listchars=tab:>-')\<CR>")
+  call term_sendkeys(buf, ":call win_execute(winid3, 'syntax match HiddenSecret /SECRET/ conceal containedin=ALL')\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_conceal_03', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2
index 40ab10bfe4639217408926a799f145a515bef4d6..46dcdaf5bc187646a55ae2cbc9bd501f42737812 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    94,
 /**/
     93,
 /**/