aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-04-28 23:38:34 +0200
committerGitHub <noreply@github.com>2024-04-29 05:38:34 +0800
commit54d8786d102c174327d6c78fe99f6c0f58022b34 (patch)
tree2a1e1cf81a0c9d32e7fa989a8086a43e9af4f683 /src
parent61063653b06bfccac083c0105ecd0c433b3bb8f7 (diff)
downloadrneovim-54d8786d102c174327d6c78fe99f6c0f58022b34.tar.gz
rneovim-54d8786d102c174327d6c78fe99f6c0f58022b34.tar.bz2
rneovim-54d8786d102c174327d6c78fe99f6c0f58022b34.zip
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) https://github.com/vim/vim/commit/32d701f51b1ed2834071a2c5031a300936beda13
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawscreen.c2
-rw-r--r--src/nvim/move.c9
-rw-r--r--src/nvim/plines.c19
3 files changed, 14 insertions, 16 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index a01cbe6223..c43acae173 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -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;
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 459841827d..377ccd7596 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -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;
}
}
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 0c55e2fd72..7a5c845c2f 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -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".