mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0380: Calculating line height for unnecessary amount of lines (#28553)
Problem: Calculating line height for unnecessary amount of lines with
half-page scrolling (zhscn, after 9.1.0280)
Solution: Replace "limit_winheight" argument with higher resolution
"max" argument to which to limit the calculated line height
in plines_m_win() to (Luuk van Baal)
32d701f51b
This commit is contained in:
parent
61063653b0
commit
54d8786d10
@ -1703,7 +1703,7 @@ static void win_update(win_T *wp)
|
||||
j = wp->w_lines[0].wl_lnum - wp->w_topline;
|
||||
}
|
||||
if (j < wp->w_grid.rows - 2) { // not too far off
|
||||
int i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1, true);
|
||||
int i = plines_m_win(wp, wp->w_topline, wp->w_lines[0].wl_lnum - 1, wp->w_height_inner);
|
||||
// insert extra lines for previously invisible filler lines
|
||||
if (wp->w_lines[0].wl_lnum != wp->w_topline) {
|
||||
i += win_get_fill(wp, wp->w_lines[0].wl_lnum) - wp->w_old_topfill;
|
||||
|
@ -1051,7 +1051,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
||||
linenr_T lnum = pos->lnum;
|
||||
if (lnum >= wp->w_topline && lnum <= wp->w_botline) {
|
||||
is_folded = hasFolding(wp, lnum, &lnum, NULL);
|
||||
row = plines_m_win(wp, wp->w_topline, lnum - 1, false);
|
||||
row = plines_m_win(wp, wp->w_topline, lnum - 1, INT_MAX);
|
||||
// "row" should be the screen line where line "lnum" begins, which can
|
||||
// be negative if "lnum" is "w_topline" and "w_skipcol" is non-zero.
|
||||
row -= adjust_plines_for_skipcol(wp);
|
||||
@ -2466,12 +2466,13 @@ int pagescroll(Direction dir, int count, bool half)
|
||||
|
||||
int curscount = count;
|
||||
// Adjust count so as to not reveal end of buffer lines.
|
||||
if (dir == FORWARD) {
|
||||
if (dir == FORWARD
|
||||
&& (curwin->w_topline + curwin->w_height + count > buflen || hasAnyFolding(curwin))) {
|
||||
int n = plines_correct_topline(curwin, curwin->w_topline, NULL, false, NULL);
|
||||
if (n - count < curwin->w_height_inner && curwin->w_topline < buflen) {
|
||||
n += plines_m_win(curwin, curwin->w_topline + 1, buflen, false);
|
||||
n += plines_m_win(curwin, curwin->w_topline + 1, buflen, curwin->w_height_inner + count);
|
||||
}
|
||||
if (n - count < curwin->w_height_inner) {
|
||||
if (n < curwin->w_height_inner + count) {
|
||||
count = n - curwin->w_height_inner;
|
||||
}
|
||||
}
|
||||
|
@ -866,21 +866,21 @@ int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp, bool *const
|
||||
(lnum == wp->w_topline ? wp->w_topfill : win_get_fill(wp, lnum)));
|
||||
}
|
||||
|
||||
/// Get the number of screen lines a range of buffer lines will take in window "wp".
|
||||
/// This takes care of both folds and topfill.
|
||||
/// Return number of window lines a physical line range will occupy in window "wp".
|
||||
/// Takes into account folding, 'wrap', topfill and filler lines beyond the end of the buffer.
|
||||
///
|
||||
/// XXX: Because of topfill, this only makes sense when first >= wp->w_topline.
|
||||
///
|
||||
/// @param first first line number
|
||||
/// @param last last line number
|
||||
/// @param limit_winheight when true limit each line to window height
|
||||
/// @param first first line number
|
||||
/// @param last last line number
|
||||
/// @param max number of lines to limit the height to
|
||||
///
|
||||
/// @see win_text_height
|
||||
int plines_m_win(win_T *wp, linenr_T first, linenr_T last, bool limit_winheight)
|
||||
int plines_m_win(win_T *wp, linenr_T first, linenr_T last, int max)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
while (first <= last && (!limit_winheight || count < wp->w_height_inner)) {
|
||||
while (first <= last && count < max) {
|
||||
linenr_T next = first;
|
||||
count += plines_win_full(wp, first, &next, NULL, false, false);
|
||||
first = next + 1;
|
||||
@ -888,10 +888,7 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last, bool limit_winheight)
|
||||
if (first == wp->w_buffer->b_ml.ml_line_count + 1) {
|
||||
count += win_get_fill(wp, first);
|
||||
}
|
||||
if (limit_winheight && count > wp->w_height_inner) {
|
||||
return wp->w_height_inner;
|
||||
}
|
||||
return count;
|
||||
return MIN(max, count);
|
||||
}
|
||||
|
||||
/// Get the number of screen lines a range of text will take in window "wp".
|
||||
|
Loading…
Reference in New Issue
Block a user