mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
fold: add const to hasFoldingWin() variables
cache is bool so update callers to pass true/false, not TRUE/FALSE.
This commit is contained in:
@@ -1486,7 +1486,7 @@ int diff_check(win_T *wp, linenr_T lnum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A closed fold never has filler lines.
|
// A closed fold never has filler lines.
|
||||||
if (hasFoldingWin(wp, lnum, NULL, NULL, TRUE, NULL)) {
|
if (hasFoldingWin(wp, lnum, NULL, NULL, true, NULL)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1793,7 +1793,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin)
|
|||||||
|
|
||||||
check_topfill(towin, false);
|
check_topfill(towin, false);
|
||||||
(void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
|
(void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline,
|
||||||
NULL, TRUE, NULL);
|
NULL, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is called when 'diffopt' is changed.
|
/// This is called when 'diffopt' is changed.
|
||||||
|
@@ -147,29 +147,27 @@ int hasAnyFolding(win_T *win)
|
|||||||
*/
|
*/
|
||||||
bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
|
bool hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp)
|
||||||
{
|
{
|
||||||
return hasFoldingWin(curwin, lnum, firstp, lastp, TRUE, NULL);
|
return hasFoldingWin(curwin, lnum, firstp, lastp, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hasFoldingWin() {{{2 */
|
/* hasFoldingWin() {{{2 */
|
||||||
bool hasFoldingWin(
|
bool hasFoldingWin(
|
||||||
win_T *win,
|
win_T *const win,
|
||||||
linenr_T lnum,
|
const linenr_T lnum,
|
||||||
linenr_T *firstp,
|
linenr_T *const firstp,
|
||||||
linenr_T *lastp,
|
linenr_T *const lastp,
|
||||||
int cache, /* when TRUE: use cached values of window */
|
const bool cache, // when true: use cached values of window
|
||||||
foldinfo_T *infop /* where to store fold info */
|
foldinfo_T *const infop // where to store fold info
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool had_folded = false;
|
bool had_folded = false;
|
||||||
linenr_T first = 0;
|
linenr_T first = 0;
|
||||||
linenr_T last = 0;
|
linenr_T last = 0;
|
||||||
linenr_T lnum_rel = lnum;
|
linenr_T lnum_rel = lnum;
|
||||||
int x;
|
|
||||||
fold_T *fp;
|
fold_T *fp;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
bool use_level = false;
|
bool use_level = false;
|
||||||
bool maybe_small = false;
|
bool maybe_small = false;
|
||||||
garray_T *gap;
|
|
||||||
int low_level = 0;
|
int low_level = 0;
|
||||||
|
|
||||||
checkupdate(win);
|
checkupdate(win);
|
||||||
@@ -187,7 +185,7 @@ bool hasFoldingWin(
|
|||||||
* First look in cached info for displayed lines. This is probably
|
* First look in cached info for displayed lines. This is probably
|
||||||
* the fastest, but it can only be used if the entry is still valid.
|
* the fastest, but it can only be used if the entry is still valid.
|
||||||
*/
|
*/
|
||||||
x = find_wl_entry(win, lnum);
|
const int x = find_wl_entry(win, lnum);
|
||||||
if (x >= 0) {
|
if (x >= 0) {
|
||||||
first = win->w_lines[x].wl_lnum;
|
first = win->w_lines[x].wl_lnum;
|
||||||
last = win->w_lines[x].wl_lastlnum;
|
last = win->w_lines[x].wl_lastlnum;
|
||||||
@@ -199,7 +197,7 @@ bool hasFoldingWin(
|
|||||||
/*
|
/*
|
||||||
* Recursively search for a fold that contains "lnum".
|
* Recursively search for a fold that contains "lnum".
|
||||||
*/
|
*/
|
||||||
gap = &win->w_folds;
|
garray_T *gap = &win->w_folds;
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
if (!foldFind(gap, lnum_rel, &fp))
|
if (!foldFind(gap, lnum_rel, &fp))
|
||||||
break;
|
break;
|
||||||
@@ -296,8 +294,9 @@ long foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop)
|
|||||||
{
|
{
|
||||||
linenr_T last;
|
linenr_T last;
|
||||||
|
|
||||||
if (hasFoldingWin(win, lnum, NULL, &last, FALSE, infop))
|
if (hasFoldingWin(win, lnum, NULL, &last, false, infop)) {
|
||||||
return (long)(last - lnum + 1);
|
return (long)(last - lnum + 1);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -783,16 +783,18 @@ static void win_update(win_T *wp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL);
|
(void)hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL);
|
||||||
if (mod_top > lnumt)
|
if (mod_top > lnumt) {
|
||||||
mod_top = lnumt;
|
mod_top = lnumt;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now do the same for the bottom line (one above mod_bot). */
|
// Now do the same for the bottom line (one above mod_bot).
|
||||||
--mod_bot;
|
mod_bot--;
|
||||||
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL);
|
(void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, true, NULL);
|
||||||
++mod_bot;
|
mod_bot++;
|
||||||
if (mod_bot < lnumb)
|
if (mod_bot < lnumb) {
|
||||||
mod_bot = lnumb;
|
mod_bot = lnumb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When a change starts above w_topline and the end is below
|
/* When a change starts above w_topline and the end is below
|
||||||
@@ -876,7 +878,7 @@ static void win_update(win_T *wp)
|
|||||||
++j;
|
++j;
|
||||||
if (j >= wp->w_height - 2)
|
if (j >= wp->w_height - 2)
|
||||||
break;
|
break;
|
||||||
(void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL);
|
(void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
j = wp->w_lines[0].wl_lnum - wp->w_topline;
|
j = wp->w_lines[0].wl_lnum - wp->w_topline;
|
||||||
@@ -1307,15 +1309,15 @@ static void win_update(win_T *wp)
|
|||||||
/* Able to count old number of rows: Count new window
|
/* Able to count old number of rows: Count new window
|
||||||
* rows, and may insert/delete lines */
|
* rows, and may insert/delete lines */
|
||||||
j = idx;
|
j = idx;
|
||||||
for (l = lnum; l < mod_bot; ++l) {
|
for (l = lnum; l < mod_bot; l++) {
|
||||||
if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL))
|
if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) {
|
||||||
++new_rows;
|
new_rows++;
|
||||||
else if (l == wp->w_topline)
|
} else if (l == wp->w_topline) {
|
||||||
new_rows += plines_win_nofill(wp, l, TRUE)
|
new_rows += plines_win_nofill(wp, l, true) + wp->w_topfill;
|
||||||
+ wp->w_topfill;
|
} else {
|
||||||
else
|
new_rows += plines_win(wp, l, true);
|
||||||
new_rows += plines_win(wp, l, TRUE);
|
}
|
||||||
++j;
|
j++;
|
||||||
if (new_rows > wp->w_height - row - 2) {
|
if (new_rows > wp->w_height - row - 2) {
|
||||||
/* it's getting too much, must redraw the rest */
|
/* it's getting too much, must redraw the rest */
|
||||||
new_rows = 9999;
|
new_rows = 9999;
|
||||||
@@ -5525,10 +5527,12 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
|
|||||||
&& re_multiline(shl->rm.regprog)) {
|
&& re_multiline(shl->rm.regprog)) {
|
||||||
if (shl->first_lnum == 0) {
|
if (shl->first_lnum == 0) {
|
||||||
for (shl->first_lnum = lnum;
|
for (shl->first_lnum = lnum;
|
||||||
shl->first_lnum > wp->w_topline; --shl->first_lnum)
|
shl->first_lnum > wp->w_topline;
|
||||||
if (hasFoldingWin(wp, shl->first_lnum - 1,
|
shl->first_lnum--) {
|
||||||
NULL, NULL, TRUE, NULL))
|
if (hasFoldingWin(wp, shl->first_lnum - 1, NULL, NULL, true, NULL)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
cur->pos.cur = 0;
|
cur->pos.cur = 0;
|
||||||
|
Reference in New Issue
Block a user