]> granicus.if.org Git - vim/commitdiff
patch 8.2.1414: popupwindow missing last couple of lines v8.2.1414
authorBram Moolenaar <Bram@vim.org>
Mon, 10 Aug 2020 18:39:17 +0000 (20:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 10 Aug 2020 18:39:17 +0000 (20:39 +0200)
Problem:    Popupwindow missing last couple of lines when cursor is in the
            first line.
Solution:   Compute the max height also when top aligned. (closes #6664)

src/popupwin.c
src/testdir/dumps/Test_popupwin_nospace.dump
src/testdir/dumps/Test_popupwin_toohigh_3.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index 5325bf6f186c5b3991ddd295ff8cea67e84f06c1..cc0843bfc2c638a4bc751485701739f3ebdf4f5a 100644 (file)
@@ -1134,6 +1134,7 @@ popup_adjust_position(win_T *wp)
     int                wantline = wp->w_wantline;  // adjusted for textprop
     int                wantcol = wp->w_wantcol;    // adjusted for textprop
     int                use_wantcol = wantcol != 0;
+    int                adjust_height_for_top_aligned = FALSE;
 
     wp->w_winrow = 0;
     wp->w_wincol = 0;
@@ -1483,16 +1484,7 @@ popup_adjust_position(win_T *wp)
            // Not enough space and more space on the other side: make top
            // aligned.
            wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1;
-           if (wp->w_winrow + wp->w_height + extra_height >= Rows)
-           {
-               wp->w_height = Rows - wp->w_winrow - extra_height;
-               if (wp->w_want_scrollbar
-#ifdef FEAT_TERMINAL
-                           && wp->w_buffer->b_term == NULL
-#endif
-                           )
-                   wp->w_has_scrollbar = TRUE;
-           }
+           adjust_height_for_top_aligned = TRUE;
        }
     }
     else if (wp->w_popup_pos == POPPOS_TOPRIGHT
@@ -1513,9 +1505,25 @@ popup_adjust_position(win_T *wp)
            }
        }
        else
+       {
            wp->w_winrow = wantline - 1;
+           adjust_height_for_top_aligned = TRUE;
+       }
     }
-    // make sure w_window is valid
+
+    if (adjust_height_for_top_aligned && wp->w_want_scrollbar
+                         && wp->w_winrow + wp->w_height + extra_height > Rows)
+    {
+       // Bottom of the popup goes below the last line, reduce the height and
+       // add a scrollbar.
+       wp->w_height = Rows - wp->w_winrow - extra_height;
+#ifdef FEAT_TERMINAL
+       if (wp->w_buffer->b_term == NULL)
+#endif
+           wp->w_has_scrollbar = TRUE;
+    }
+
+    // make sure w_winrow is valid
     if (wp->w_winrow >= Rows)
        wp->w_winrow = Rows - 1;
     else if (wp->w_winrow < 0)
index 9eaacf066f584558f345c59b3fab0165cb5f6398..de8521c0dff376580feb5261db4ddcc9fcd1e90e 100644 (file)
@@ -3,10 +3,10 @@
 |-|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@11| @14
 |-|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@11| @14
 |-|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|o|u|║|-+0#0000000#ffffff0@1>*|-@8| @14
-|-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|i|v|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@4| @14
-|-@14|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@15|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|a@2|║|-+0#0000000#ffffff0@4| @14
-|-@14|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|*|-@5|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|b@2|║|-+0#0000000#ffffff0@4| @14
-|-@14|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|c@2|║|-+0#0000000#ffffff0@4| @14
-|-@14|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|d@2|║|-+0#0000000#ffffff0@4| @14
-|-@28|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@4| @14
-@29|â\95\9a+0#0000001#ffd7ff255|â\95\90@2|â\95\9d| +0#0000000#ffffff0@1|â\95\91+0#0000001#ffd7ff255|t|e@1|â\95\91| +0#0000000#ffffff0@8|â\95\91+0#0000001#ffd7ff255|f@2|â\95\91| +0#0000000#ffffff0@1|5|,|5|1| @9|T|o|p| 
+|-@14|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|e@2|║|-+0#0000000#ffffff0@15|║+0#0000001#ffd7ff255|f|i|v|║|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@3|╗|-+0#0000000#ffffff0@3| @14
+|-@14|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@15|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|a@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
+|-@14|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|*|-@5|@|-@5|#|-@5|%|-@5|║+0#0000001#ffd7ff255|b@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
+|-@14|║+0#0000001#ffd7ff255|t|e@1|║|-+0#0000000#ffffff0@8|╔+0#0000001#ffd7ff255|═@2|╗|-+0#0000000#ffffff0@1|╔+0#0000001#ffd7ff255|═@3|╗|-+0#0000000#ffffff0@7|║+0#0000001#ffd7ff255|c@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
+|-@14|╚+0#0000001#ffd7ff255|═@2|╝|-+0#0000000#ffffff0@8|║+0#0000001#ffd7ff255|o|n|e|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|o|n|e| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@7|║+0#0000001#ffd7ff255|d@2| +0#0000000#0000001|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
+|-@28|║+0#0000001#ffd7ff255|t|w|o|║|-+0#0000000#ffffff0@1|║+0#0000001#ffd7ff255|t|w|o| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@7|║+0#0000001#ffd7ff255|e@2| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255|-+0#0000000#ffffff0@3| @14
+@29|â\95\9a+0#0000001#ffd7ff255|â\95\90@2|â\95\9d| +0#0000000#ffffff0@1|â\95\9a+0#0000001#ffd7ff255|â\95\90@3|â\95\9d| +0#0000000#ffffff0@7|â\95\9a+0#0000001#ffd7ff255|â\95\90@3|â\95\9d| +0#0000000#ffffff0|5|,|5|1| @9|T|o|p| 
diff --git a/src/testdir/dumps/Test_popupwin_toohigh_3.dump b/src/testdir/dumps/Test_popupwin_toohigh_3.dump
new file mode 100644 (file)
index 0000000..8c15a40
--- /dev/null
@@ -0,0 +1,10 @@
+|1+0&#ffffff0@8>1| @64
+|2@8|╔+0#0000001#ffd7ff255|═@8|╗| +0#0000000#ffffff0@54
+|3@8|║+0#0000001#ffd7ff255|o|n|e| @4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|4@8|║+0#0000001#ffd7ff255|t|w|o| @4| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|5@8|║+0#0000001#ffd7ff255|t|h|r|e@1| @2| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|6@8|║+0#0000001#ffd7ff255|f|o|u|r| @3| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|7@8|║+0#0000001#ffd7ff255|f|i|v|e| @3| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|8@8|║+0#0000001#ffd7ff255|s|i|x| @4| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|9@8|║+0#0000001#ffd7ff255|s|e|v|e|n| @2| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@54
+|:|c|a|l@1| |S|h|o|╚+0#0000001#ffd7ff255|═@8|╝| +0#0000000#ffffff0@36|1|,|1|0| @9|T|o|p| 
index c44c8476198a091f0d2e01613163752231546ef2..f13a7e057c13ed4e1565de763cdccfbfcb3f9eab 100644 (file)
@@ -753,6 +753,7 @@ func Test_popup_with_mask()
            \ posinvert: 0,
            \ wrap: 0,
            \ fixed: 1,
+           \ scrollbar: v:false,
            \ zindex: 90,
            \ padding: [],
            \ highlight: 'PopupColor',
@@ -772,6 +773,7 @@ func Test_popup_with_mask()
            \ posinvert: 0,
            \ wrap: 0,
            \ fixed: 1,
+           \ scrollbar: v:false,
            \ close: 'button',
            \ zindex: 90,
            \ padding: [],
@@ -2169,6 +2171,11 @@ func Test_popup_too_high_scrollbar()
   call term_sendkeys(buf, ":call ShowPopup()\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_toohigh_2', {})
 
+  call term_sendkeys(buf, ":call popup_clear()\<CR>")
+  call term_sendkeys(buf, "gg$")
+  call term_sendkeys(buf, ":call ShowPopup()\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_toohigh_3', {})
+
   " clean up
   call StopVimInTerminal(buf)
   call delete('XtestPopupToohigh')
index a08b5d7b02342e2f07cce1401f3ecde45b0d6eba..38dc86fa477e9188bc1df31754544d694df69ef9 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1414,
 /**/
     1413,
 /**/