comparison src/popupwin.c @ 21713:b997e872ff95 v8.2.1406

patch 8.2.1406: popupwindow lacks scrollbar if no "maxheight" is used Commit: https://github.com/vim/vim/commit/a1b9b0cc011ef15869ac25cb93e1b4baa0cb7f38 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 9 16:37:48 2020 +0200 patch 8.2.1406: popupwindow lacks scrollbar if no "maxheight" is used Problem: Popupwindow lacks scrollbar if no "maxheight" is used. Solution: Compute the max height depending on the position. (closes https://github.com/vim/vim/issues/6664)
author Bram Moolenaar <Bram@vim.org>
date Sun, 09 Aug 2020 16:45:04 +0200
parents 27bbd918e70c
children f2ba8ebbab2b
comparison
equal deleted inserted replaced
21712:5294e38bd231 21713:b997e872ff95
1128 int org_width = wp->w_width; 1128 int org_width = wp->w_width;
1129 int org_height = wp->w_height; 1129 int org_height = wp->w_height;
1130 int org_leftcol = wp->w_leftcol; 1130 int org_leftcol = wp->w_leftcol;
1131 int org_leftoff = wp->w_popup_leftoff; 1131 int org_leftoff = wp->w_popup_leftoff;
1132 int minwidth, minheight; 1132 int minwidth, minheight;
1133 int maxheight = Rows;
1133 int wantline = wp->w_wantline; // adjusted for textprop 1134 int wantline = wp->w_wantline; // adjusted for textprop
1134 int wantcol = wp->w_wantcol; // adjusted for textprop 1135 int wantcol = wp->w_wantcol; // adjusted for textprop
1135 int use_wantcol = wantcol != 0; 1136 int use_wantcol = wantcol != 0;
1136 1137
1137 wp->w_winrow = 0; 1138 wp->w_winrow = 0;
1275 if (minheight == 0) 1276 if (minheight == 0)
1276 minheight = 5; 1277 minheight = 5;
1277 } 1278 }
1278 #endif 1279 #endif
1279 1280
1281 if (wp->w_maxheight > 0)
1282 maxheight = wp->w_maxheight;
1283
1280 // start at the desired first line 1284 // start at the desired first line
1281 if (wp->w_firstline > 0) 1285 if (wp->w_firstline > 0)
1282 wp->w_topline = wp->w_firstline; 1286 wp->w_topline = wp->w_firstline;
1283 if (wp->w_topline < 1) 1287 if (wp->w_topline < 1)
1284 wp->w_topline = 1; 1288 wp->w_topline = 1;
1351 --lnum; 1355 --lnum;
1352 else 1356 else
1353 ++lnum; 1357 ++lnum;
1354 1358
1355 // do not use the width of lines we're not going to show 1359 // do not use the width of lines we're not going to show
1356 if (wp->w_maxheight > 0 1360 if (maxheight > 0
1357 && (wp->w_firstline >= 0 1361 && (wp->w_firstline >= 0
1358 ? lnum - wp->w_topline 1362 ? lnum - wp->w_topline
1359 : wp->w_buffer->b_ml.ml_line_count - lnum) 1363 : wp->w_buffer->b_ml.ml_line_count - lnum)
1360 + wrapped >= wp->w_maxheight) 1364 + wrapped >= maxheight)
1361 break; 1365 break;
1362 } 1366 }
1363 1367
1364 if (wp->w_firstline < 0) 1368 if (wp->w_firstline < 0)
1365 wp->w_topline = lnum > 0 ? lnum + 1 : lnum; 1369 wp->w_topline = lnum > 0 ? lnum + 1 : lnum;
1447 1451
1448 wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline 1452 wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline
1449 + 1 + wrapped; 1453 + 1 + wrapped;
1450 if (minheight > 0 && wp->w_height < minheight) 1454 if (minheight > 0 && wp->w_height < minheight)
1451 wp->w_height = minheight; 1455 wp->w_height = minheight;
1452 if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight) 1456 if (maxheight > 0 && wp->w_height > maxheight)
1453 wp->w_height = wp->w_maxheight; 1457 wp->w_height = maxheight;
1454 w_height_before_limit = wp->w_height; 1458 w_height_before_limit = wp->w_height;
1455 if (wp->w_height > Rows - wp->w_winrow) 1459 if (wp->w_height > Rows - wp->w_winrow)
1456 wp->w_height = Rows - wp->w_winrow; 1460 wp->w_height = Rows - wp->w_winrow;
1457 if (wp->w_height != org_height)
1458 win_comp_scroll(wp);
1459 1461
1460 if (center_vert) 1462 if (center_vert)
1461 { 1463 {
1462 wp->w_winrow = (Rows - wp->w_height - extra_height) / 2; 1464 wp->w_winrow = (Rows - wp->w_height - extra_height) / 2;
1463 if (wp->w_winrow < 0) 1465 if (wp->w_winrow < 0)
1475 // side or "posinvert" is off: reduce height. 1477 // side or "posinvert" is off: reduce height.
1476 wp->w_winrow = 0; 1478 wp->w_winrow = 0;
1477 wp->w_height = wantline - extra_height; 1479 wp->w_height = wantline - extra_height;
1478 } 1480 }
1479 else 1481 else
1482 {
1480 // Not enough space and more space on the other side: make top 1483 // Not enough space and more space on the other side: make top
1481 // aligned. 1484 // aligned.
1482 wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1; 1485 wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1;
1486 if (wp->w_winrow + wp->w_height + extra_height >= Rows)
1487 {
1488 wp->w_height = Rows - wp->w_winrow - extra_height;
1489 if (wp->w_want_scrollbar
1490 #ifdef FEAT_TERMINAL
1491 && wp->w_buffer->b_term == NULL
1492 #endif
1493 )
1494 wp->w_has_scrollbar = TRUE;
1495 }
1496 }
1483 } 1497 }
1484 else if (wp->w_popup_pos == POPPOS_TOPRIGHT 1498 else if (wp->w_popup_pos == POPPOS_TOPRIGHT
1485 || wp->w_popup_pos == POPPOS_TOPLEFT) 1499 || wp->w_popup_pos == POPPOS_TOPLEFT)
1486 { 1500 {
1487 if (wantline + (wp->w_height + extra_height) - 1 > Rows 1501 if (wantline + (wp->w_height + extra_height) - 1 > Rows
1499 } 1513 }
1500 } 1514 }
1501 else 1515 else
1502 wp->w_winrow = wantline - 1; 1516 wp->w_winrow = wantline - 1;
1503 } 1517 }
1518 // make sure w_window is valid
1504 if (wp->w_winrow >= Rows) 1519 if (wp->w_winrow >= Rows)
1505 wp->w_winrow = Rows - 1; 1520 wp->w_winrow = Rows - 1;
1506 else if (wp->w_winrow < 0) 1521 else if (wp->w_winrow < 0)
1507 wp->w_winrow = 0; 1522 wp->w_winrow = 0;
1523
1524 if (wp->w_height != org_height)
1525 win_comp_scroll(wp);
1508 1526
1509 wp->w_popup_last_changedtick = CHANGEDTICK(wp->w_buffer); 1527 wp->w_popup_last_changedtick = CHANGEDTICK(wp->w_buffer);
1510 if (win_valid(wp->w_popup_prop_win)) 1528 if (win_valid(wp->w_popup_prop_win))
1511 { 1529 {
1512 wp->w_popup_prop_changedtick = 1530 wp->w_popup_prop_changedtick =