mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor(plines): remove implicit curwin plines_nofill() function
This commit is contained in:
parent
a177c7df09
commit
0465341e16
@ -1055,8 +1055,9 @@ bool scrolldown(long line_count, int byfold)
|
||||
line_count -= curwin->w_topline - first - 1;
|
||||
curwin->w_botline -= curwin->w_topline - first;
|
||||
curwin->w_topline = first;
|
||||
} else
|
||||
done += plines_nofill(curwin->w_topline);
|
||||
} else {
|
||||
done += plines_win_nofill(curwin, curwin->w_topline, true);
|
||||
}
|
||||
}
|
||||
--curwin->w_botline; /* approximate w_botline */
|
||||
invalidate_botline();
|
||||
@ -1195,7 +1196,7 @@ check_topfill (
|
||||
*/
|
||||
static void max_topfill(void)
|
||||
{
|
||||
int n = plines_nofill(curwin->w_topline);
|
||||
int n = plines_win_nofill(curwin, curwin->w_topline, true);
|
||||
if (n >= curwin->w_height_inner) {
|
||||
curwin->w_topfill = 0;
|
||||
} else {
|
||||
@ -1222,19 +1223,16 @@ void scrolldown_clamp(void)
|
||||
|
||||
validate_cursor(); /* w_wrow needs to be valid */
|
||||
|
||||
/*
|
||||
* Compute the row number of the last row of the cursor line
|
||||
* and make sure it doesn't go off the screen. Make sure the cursor
|
||||
* doesn't go past 'scrolloff' lines from the screen end.
|
||||
*/
|
||||
// Compute the row number of the last row of the cursor line
|
||||
// and make sure it doesn't go off the screen. Make sure the cursor
|
||||
// doesn't go past 'scrolloff' lines from the screen end.
|
||||
int end_row = curwin->w_wrow;
|
||||
if (can_fill)
|
||||
++end_row;
|
||||
else
|
||||
end_row += plines_nofill(curwin->w_topline - 1);
|
||||
if (curwin->w_p_wrap
|
||||
&& curwin->w_width_inner != 0
|
||||
) {
|
||||
if (can_fill) {
|
||||
end_row++;
|
||||
} else {
|
||||
end_row += plines_win_nofill(curwin, curwin->w_topline - 1, true);
|
||||
}
|
||||
if (curwin->w_p_wrap && curwin->w_width_inner != 0) {
|
||||
validate_cheight();
|
||||
validate_virtcol();
|
||||
end_row += curwin->w_cline_height - 1 -
|
||||
@ -1267,16 +1265,13 @@ void scrollup_clamp(void)
|
||||
|
||||
validate_cursor(); /* w_wrow needs to be valid */
|
||||
|
||||
/*
|
||||
* Compute the row number of the first row of the cursor line
|
||||
* and make sure it doesn't go off the screen. Make sure the cursor
|
||||
* doesn't go before 'scrolloff' lines from the screen start.
|
||||
*/
|
||||
int start_row = curwin->w_wrow - plines_nofill(curwin->w_topline)
|
||||
- curwin->w_topfill;
|
||||
if (curwin->w_p_wrap
|
||||
&& curwin->w_width_inner != 0
|
||||
) {
|
||||
// Compute the row number of the first row of the cursor line
|
||||
// and make sure it doesn't go off the screen. Make sure the cursor
|
||||
// doesn't go before 'scrolloff' lines from the screen start.
|
||||
int start_row = (curwin->w_wrow
|
||||
- plines_win_nofill(curwin, curwin->w_topline, true)
|
||||
- curwin->w_topfill);
|
||||
if (curwin->w_p_wrap && curwin->w_width_inner != 0) {
|
||||
validate_virtcol();
|
||||
start_row -= curwin->w_virtcol / curwin->w_width_inner;
|
||||
}
|
||||
@ -1423,7 +1418,7 @@ void scroll_cursor_top(int min_scroll, int always)
|
||||
while (top > 0) {
|
||||
int i = hasFolding(top, &top, NULL)
|
||||
? 1 // count one logical line for a sequence of folded lines
|
||||
: plines_nofill(top);
|
||||
: plines_win_nofill(curwin, top, true);
|
||||
used += i;
|
||||
if (extra + i <= off && bot < curbuf->b_ml.ml_line_count) {
|
||||
if (hasFolding(bot, NULL, &bot)) {
|
||||
@ -1557,12 +1552,12 @@ void scroll_cursor_bot(int min_scroll, int set_topbot)
|
||||
validate_botline(curwin);
|
||||
}
|
||||
|
||||
/* The lines of the cursor line itself are always used. */
|
||||
used = plines_nofill(cln);
|
||||
// The lines of the cursor line itself are always used.
|
||||
used = plines_win_nofill(curwin, cln, true);
|
||||
|
||||
/* If the cursor is below botline, we will at least scroll by the height
|
||||
* of the cursor line. Correct for empty lines, which are really part of
|
||||
* botline. */
|
||||
// If the cursor is below botline, we will at least scroll by the height
|
||||
// of the cursor line. Correct for empty lines, which are really part of
|
||||
// botline.
|
||||
if (cln >= curwin->w_botline) {
|
||||
scrolled = used;
|
||||
if (cln == curwin->w_botline)
|
||||
@ -1706,7 +1701,7 @@ void scroll_cursor_halfway(int atend)
|
||||
|
||||
loff.lnum = boff.lnum = curwin->w_cursor.lnum;
|
||||
(void)hasFolding(loff.lnum, &loff.lnum, &boff.lnum);
|
||||
int used = plines_nofill(loff.lnum);
|
||||
int used = plines_win_nofill(curwin, loff.lnum, true);
|
||||
loff.fill = 0;
|
||||
boff.fill = 0;
|
||||
linenr_T topline = loff.lnum;
|
||||
@ -1819,10 +1814,11 @@ void cursor_correct(void)
|
||||
botline--;
|
||||
}
|
||||
if (above < above_wanted && (above < below || below >= below_wanted)) {
|
||||
if (hasFolding(topline, NULL, &topline))
|
||||
++above;
|
||||
else
|
||||
above += plines_nofill(topline);
|
||||
if (hasFolding(topline, NULL, &topline)) {
|
||||
above++;
|
||||
} else {
|
||||
above += plines_win_nofill(curwin, topline, true);
|
||||
}
|
||||
|
||||
/* Count filler lines below this line as context. */
|
||||
if (topline < botline)
|
||||
@ -2050,10 +2046,11 @@ static void get_scroll_overlap(lineoff_T *lp, int dir)
|
||||
{
|
||||
int min_height = curwin->w_height_inner - 2;
|
||||
|
||||
if (lp->fill > 0)
|
||||
if (lp->fill > 0) {
|
||||
lp->height = 1;
|
||||
else
|
||||
lp->height = plines_nofill(lp->lnum);
|
||||
} else {
|
||||
lp->height = plines_win_nofill(curwin, lp->lnum, true);
|
||||
}
|
||||
int h1 = lp->height;
|
||||
if (h1 > min_height)
|
||||
return; /* no overlap */
|
||||
@ -2123,7 +2120,7 @@ void halfpage(bool flag, linenr_T Prenum)
|
||||
n--;
|
||||
curwin->w_topfill--;
|
||||
} else {
|
||||
i = plines_nofill(curwin->w_topline);
|
||||
i = plines_win_nofill(curwin, curwin->w_topline, true);
|
||||
n -= i;
|
||||
if (n < 0 && scrolled > 0)
|
||||
break;
|
||||
@ -2183,7 +2180,7 @@ void halfpage(bool flag, linenr_T Prenum)
|
||||
n--;
|
||||
curwin->w_topfill++;
|
||||
} else {
|
||||
i = plines_nofill(curwin->w_topline - 1);
|
||||
i = plines_win_nofill(curwin, curwin->w_topline - 1, true);
|
||||
n -= i;
|
||||
if (n < 0 && scrolled > 0)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user