Patch 8.1.2164
Problem:    Stuck when using "j" in a popupwin with popup_filter_menu if a
            line wraps.
Solution:   Check the cursor line is visible. (closes #4577)
Files:      src/popupwin.c, src/testdir/test_popupwin.vim,
            src/testdir/dumps/Test_popupwin_wrap_1.dump,
            src/testdir/dumps/Test_popupwin_wrap_2.dump


*** ../vim-8.1.2163/src/popupwin.c      2019-10-05 11:56:49.670415784 +0200
--- src/popupwin.c      2019-10-16 22:15:09.867841759 +0200
***************
*** 535,541 ****
  }
  
  /*
!  * Scroll to show the line with the cursor.  This assumes lines don't wrap.
   */
      static void
  popup_show_curline(win_T *wp)
--- 535,541 ----
  }
  
  /*
!  * Scroll to show the line with the cursor.
   */
      static void
  popup_show_curline(win_T *wp)
***************
*** 550,555 ****
--- 550,560 ----
            wp->w_topline = 1;
        else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
            wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
+       while (wp->w_topline < wp->w_cursor.lnum
+               && wp->w_topline < wp->w_buffer->b_ml.ml_line_count
+               && plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum)
+                                                               > wp->w_height)
+           ++wp->w_topline;
      }
  
      // Don't use "firstline" now.
***************
*** 1041,1046 ****
--- 1046,1052 ----
      linenr_T  lnum;
      int               wrapped = 0;
      int               maxwidth;
+     int               used_maxwidth = FALSE;
      int               maxspace;
      int               center_vert = FALSE;
      int               center_hor = FALSE;
***************
*** 1208,1213 ****
--- 1214,1220 ----
                ++wrapped;
                len -= maxwidth;
                wp->w_width = maxwidth;
+               used_maxwidth = TRUE;
            }
        }
        else if (len > maxwidth
***************
*** 1259,1264 ****
--- 1266,1273 ----
      {
        ++right_extra;
        ++extra_width;
+       if (used_maxwidth)
+           maxwidth -= 2;  // try to show the scrollbar
      }
  
      minwidth = wp->w_minwidth;
*** ../vim-8.1.2163/src/testdir/test_popupwin.vim       2019-10-03 
22:35:46.688591474 +0200
--- src/testdir/test_popupwin.vim       2019-10-16 22:12:36.288039632 +0200
***************
*** 509,514 ****
--- 509,546 ----
    call delete('XtestPopupClose')
  endfunction
  
+ func Test_popup_menu_wrap()
+   CheckScreendump
+ 
+   let lines =<< trim END
+       call setline(1, range(1, 20))
+       call popup_create([
+             \ 'one',
+             \ 
'asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfas',
+             \ 'three',
+             \ 'four',
+             \ ], #{
+             \ pos: "botleft",
+             \ border: [],
+             \ padding: [0,1,0,1],
+             \ maxheight: 3,
+             \ cursorline: 1,
+             \ filter: 'popup_filter_menu',
+             \ })
+   END
+   call writefile(lines, 'XtestPopupWrap')
+   let buf = RunVimInTerminal('-S XtestPopupWrap', #{rows: 10})
+   call VerifyScreenDump(buf, 'Test_popupwin_wrap_1', {})
+ 
+   call term_sendkeys(buf, "jj")
+   call VerifyScreenDump(buf, 'Test_popupwin_wrap_2', {})
+ 
+   " clean up
+   call term_sendkeys(buf, "\<Esc>")
+   call StopVimInTerminal(buf)
+   call delete('XtestPopupWrap')
+ endfunction
+ 
  func Test_popup_with_mask()
    CheckScreendump
  
*** ../vim-8.1.2163/src/testdir/dumps/Test_popupwin_wrap_1.dump 2019-10-16 
22:16:29.159720392 +0200
--- src/testdir/dumps/Test_popupwin_wrap_1.dump 2019-10-16 22:10:03.984173258 
+0200
***************
*** 0 ****
--- 1,10 ----
+ >1+0&#ffffff0| @73
+ |2| @73
+ |╔+0#0000001#ffd7ff255|═@73
+ |║| |o+0&#e0e0e08|n|e| @67| +0&#ffd7ff255| +0#0000000#0000001
+ |║+0#0000001#ffd7ff255| 
|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|
 | +0#0000000#0000001
+ |║+0#0000001#ffd7ff255| |f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s| @52| 
+0#0000000#a8a8a8255
+ |╚+0#0000001#ffd7ff255|═@73
+ |8+0#0000000#ffffff0| @73
+ |9| @73
+ @57|1|,|1| @10|T|o|p| 
*** ../vim-8.1.2163/src/testdir/dumps/Test_popupwin_wrap_2.dump 2019-10-16 
22:16:29.163720387 +0200
--- src/testdir/dumps/Test_popupwin_wrap_2.dump 2019-10-16 22:10:05.032172596 
+0200
***************
*** 0 ****
--- 1,10 ----
+ >1+0&#ffffff0| @73
+ |2| @73
+ |╔+0#0000001#ffd7ff255|═@73
+ |║| 
|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|
 | +0#0000000#a8a8a8255
+ |║+0#0000001#ffd7ff255| |f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s| @52| 
+0#0000000#0000001
+ |║+0#0000001#ffd7ff255| |t+0&#e0e0e08|h|r|e@1| @65| +0&#ffd7ff255| 
+0#0000000#0000001
+ |╚+0#0000001#ffd7ff255|═@73
+ |8+0#0000000#ffffff0| @73
+ |9| @73
+ @57|1|,|1| @10|T|o|p| 
*** ../vim-8.1.2163/src/version.c       2019-10-16 21:33:37.523551169 +0200
--- src/version.c       2019-10-16 21:50:45.131385824 +0200
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     2164,
  /**/

-- 
NEIL INNES PLAYED: THE FIRST SELF-DESTRUCTIVE MONK, ROBIN'S LEAST FAVORITE
                   MINSTREL, THE PAGE CRUSHED BY A RABBIT, THE OWNER OF A DUCK
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201910162017.x9GKHcDf014704%40masaka.moolenaar.net.

Raspunde prin e-mail lui