]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0949: popups inconsistently shifted to the left v9.1.0949
authorBoris Staletic <boris.staletic@protonmail.com>
Thu, 19 Dec 2024 19:22:19 +0000 (20:22 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 19 Dec 2024 19:22:19 +0000 (20:22 +0100)
Problem:  popups inconsistently shifted to the left
Solution: always shift non-fixed popups to the left when the
          text would be truncated
          (no matter whether 'wrap' is set or not)
          (Boris Staletic)

fixes: #16231
closes: #16247

Signed-off-by: Boris Staletic <boris.staletic@protonmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/popup.txt
src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index b9e992b04cc4efa00db44bc48dbf87d966c9e7f7..b1e6c0cb350d09a0dbe1d726b7618e489625d3b9 100644 (file)
@@ -1,4 +1,4 @@
-*popup.txt*  For Vim version 9.1.  Last change: 2024 Jun 16
+*popup.txt*  For Vim version 9.1.  Last change: 2024 Dec 19
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -705,7 +705,6 @@ The second argument of |popup_create()| is a dictionary with options:
                        present. Use zero to reset.
        fixed           When FALSE (the default), and:
                         - "pos" is "botleft" or "topleft", and
-                        - "wrap" is off, and
                         - the popup would be truncated at the right edge of
                           the screen, then
                        the popup is moved to the left so as to fit the
index 8c567173f9e69cec58766833f727d8352b57da0c..404549097b1112f2ba12ce8d46e8c15acbb5076c 100644 (file)
@@ -1434,17 +1434,7 @@ popup_adjust_position(win_T *wp)
        len = linetabsize(wp, lnum);
        wp->w_width = w_width;
 
-       if (wp->w_p_wrap)
-       {
-           while (len + margin_width > maxwidth)
-           {
-               ++wrapped;
-               len -= maxwidth - margin_width;
-               wp->w_width = maxwidth;
-               used_maxwidth = TRUE;
-           }
-       }
-       else if (len + margin_width > maxwidth
+       if (len + margin_width > maxwidth
                && allow_adjust_left
                && (wp->w_popup_pos == POPPOS_TOPLEFT
                    || wp->w_popup_pos == POPPOS_BOTLEFT))
@@ -1456,7 +1446,6 @@ popup_adjust_position(win_T *wp)
            {
                int truncate_shift = shift_by - wp->w_wincol;
 
-               len -= truncate_shift;
                shift_by -= truncate_shift;
            }
 
@@ -1464,6 +1453,16 @@ popup_adjust_position(win_T *wp)
            maxwidth += shift_by;
            wp->w_width = maxwidth;
        }
+       if (wp->w_p_wrap)
+       {
+           while (len + margin_width > maxwidth)
+           {
+               ++wrapped;
+               len -= maxwidth - margin_width;
+               wp->w_width = maxwidth;
+               used_maxwidth = TRUE;
+           }
+       }
        if (wp->w_width < len + margin_width)
        {
            wp->w_width = len + margin_width;
index d345b3eed6ae498f4c6562b8b0d043c3ac55cf0b..8b6b78ff967b1701ab90d8700dc75902e78399e3 100644 (file)
@@ -31,7 +31,7 @@ func Test_simple_popup()
        \ .. "#{text: 'a comment line', props: [#{"
        \ .. "col: 3, length: 7, minwidth: 20, type: 'comment'"
        \ .. "}]},"
-       \ .. "], #{line: 4, col: 9, minwidth: 20})\<CR>")
+       \ .. "], #{line: 4, col: 9, minwidth: 20, fixed: v:true})\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_02', {})
 
   " switch back to first tabpage
@@ -87,7 +87,7 @@ func Test_popup_with_border_and_padding()
          call popup_create('hello both', #{line: 2, col: 43, border: [], padding: [], highlight: 'Normal'})
          call popup_create('border TL', #{line: 6, col: 3, border: [1, 0, 0, 4]})
          call popup_create('paddings', #{line: 6, col: 23, padding: range(1, 4)})
-         call popup_create('wrapped longer text', #{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
+         call popup_create('wrapped longer text', #{line: 8, col: 55, padding: [0, 3, 0, 3], border: [0, 1, 0, 1], fixed: v:true})
          call popup_create('right aligned text', #{line: 11, col: 56, wrap: 0, padding: [0, 3, 0, 3], border: [0, 1, 0, 1]})
          call popup_create('X', #{line: 2, col: 73})
          call popup_create('X', #{line: 3, col: 74})
@@ -1970,7 +1970,7 @@ func Test_popup_position_adjust()
   " Anything placed past the last cell on the right of the screen is moved to
   " the left.
   "
-  " When wrapping is disabled, we also shift to the left to display on the
+  " We also shift to the left to display on the
   " screen, unless fixed is set.
 
   " Entries for cases which don't vary based on wrapping.
@@ -1995,9 +1995,10 @@ func Test_popup_position_adjust()
   "     - expected height
   let tests = [
        \ #{
-       \   comment: 'left-aligned with wrapping',
+       \   comment: 'left aligned with wrapping, fixed position',
        \   options: #{
        \     wrap: 1,
+       \     fixed: v:true,
        \     pos: 'botleft',
        \   },
        \   tests: both_wrap_tests + [
@@ -2022,9 +2023,22 @@ func Test_popup_position_adjust()
        \   ],
        \ },
        \ #{
-       \   comment: 'left aligned without wrapping',
+       \   comment: 'left aligned with wrapping, no fixed position',
+       \   options: #{
+       \     wrap: 1,
+       \     fixed: v:false,
+       \     pos: 'botleft',
+       \   },
+       \   tests: both_wrap_tests + [
+       \       [ repeat('a', &columns*3), 5, &columns,   3,                 1, &columns, 3],
+       \       [ repeat('a', 50),         5, &columns,   5, &columns - 50 + 1,       50, 1],
+       \   ],
+       \ },
+       \ #{
+       \   comment: 'left aligned without wrapping, no fixed position',
        \   options: #{
        \     wrap: 0,
+       \     fixed: v:false,
        \     pos: 'botleft',
        \   },
        \   tests: both_wrap_tests + [
@@ -2048,7 +2062,7 @@ func Test_popup_position_adjust()
        \   ],
        \ },
        \ #{
-       \   comment: 'left aligned with fixed position',
+       \   comment: 'left aligned without wrapping, fixed position',
        \   options: #{
        \     wrap: 0,
        \     fixed: 1,
index 00088ff273e7136d59e0768da53dae45df7fc0d3..762919e6bb97b20a3716524ce6ae25bfb89b2f44 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    949,
 /**/
     948,
 /**/