]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0930: floating point exception when displaying pum v9.2.0930
authorChristian Brabandt <cb@256bit.org>
Mon, 10 Aug 2026 19:36:32 +0000 (19:36 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 10 Aug 2026 19:38:45 +0000 (19:38 +0000)
Problem:  floating point exception when displaying pum
          (dvaave2025)
Solution: Verify that curwin->w_width > 0

fixes:  #20985
closes: #20994

Supported by AI.

Signed-off-by: Christian Brabandt <cb@256bit.org>
src/popupmenu.c
src/testdir/test_popup.vim
src/version.c

index 36000d9bf013175686ec843bfa4955a3eccf58ac..47f9b297f73cb33101b741b2e06c16b4f230a2d6 100644 (file)
@@ -363,7 +363,10 @@ pum_display(
        {
            int wcol = pum_wcol >= 0 ? pum_wcol : curwin->w_wcol;
            // w_wcol includes virtual text "above".
-           wcol %= curwin->w_width;
+           if (curwin->w_width > 0)
+               wcol %= curwin->w_width;
+           else
+               wcol = 0;
 #ifdef FEAT_CONCEAL
            // w_wcol does not account for text concealed before the cursor;
            // shift by the offset win_line() recorded for the cursor line so the
index a4bba3f3103e880642121ac522f645664fcb9460..f5f2f1a7b77fd17f0442ca942e06d1f8edddecd9 100644 (file)
@@ -2734,4 +2734,24 @@ func Test_popup_sandbox()
   call assert_fails('sandbox call popup_setoptions(1, {})', 'E48:')
 endfunc
 
+func Test_pum_display_with_zero_width_window()
+  " Force curwin to width 0 (like Test_window_minimal_size does for
+  " win_ensure_size itself), then start completion via a non-typed,
+  " stuffed key sequence so KeyTyped stays FALSE and the repair is
+  " skipped.  pum_display() must not divide by curwin->w_width in that
+  " state (would SIGFPE).
+  set winminwidth=0
+  vert new
+  call win_execute(win_getid(2), 'wincmd |')
+  call assert_equal(0, winwidth(0))
+
+  call setline(1, ['foo', 'foobar', 'foo'])
+  call feedkeys("A\<C-N>\<Esc>", 'x')
+  call assert_equal(0, winwidth(0))
+
+  bwipe!
+  bwipe!
+  set winminwidth&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index e0bd6e1e059bd1e8c2d9d2f7e1f7dbe8189a6031..ccd788a595a5bc3f16d028c2b2c320d51434d80a 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    930,
 /**/
     929,
 /**/