hasFoldingWin now return bool

This commit is contained in:
Nicolas Cornu 2015-09-08 02:34:43 +02:00
parent 41778e2e10
commit 63a39015f5
5 changed files with 14 additions and 15 deletions

View File

@ -282,7 +282,7 @@ linenr_T get_cursor_rel_lnum(win_T *wp, linenr_T lnum)
// Loop until we reach to_line, skipping folds. // Loop until we reach to_line, skipping folds.
for (; from_line < to_line; from_line++, retval++) { for (; from_line < to_line; from_line++, retval++) {
// If from_line is in a fold, set it to the last line of that fold. // If from_line is in a fold, set it to the last line of that fold.
hasFoldingWin(wp, from_line, NULL, &from_line, true, NULL); (void)hasFoldingWin(wp, from_line, NULL, &from_line, true, NULL);
} }
// If to_line is in a closed fold, the line count is off by +1. Correct it. // If to_line is in a closed fold, the line count is off by +1. Correct it.

View File

@ -150,12 +150,11 @@ int hasAnyFolding(win_T *win)
*/ */
int hasFolding(linenr_T lnum, linenr_T *firstp, linenr_T *lastp) int 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) ? TRUE : FALSE;
} }
/* hasFoldingWin() {{{2 */ /* hasFoldingWin() {{{2 */
int bool hasFoldingWin(
hasFoldingWin (
win_T *win, win_T *win,
linenr_T lnum, linenr_T lnum,
linenr_T *firstp, linenr_T *firstp,
@ -183,7 +182,7 @@ hasFoldingWin (
if (!hasAnyFolding(win)) { if (!hasAnyFolding(win)) {
if (infop != NULL) if (infop != NULL)
infop->fi_level = 0; infop->fi_level = 0;
return FALSE; return false;
} }
if (cache) { if (cache) {
@ -238,7 +237,7 @@ hasFoldingWin (
infop->fi_lnum = lnum - lnum_rel; infop->fi_lnum = lnum - lnum_rel;
infop->fi_low_level = low_level == 0 ? level : low_level; infop->fi_low_level = low_level == 0 ? level : low_level;
} }
return FALSE; return false;
} }
if (last > win->w_buffer->b_ml.ml_line_count) { if (last > win->w_buffer->b_ml.ml_line_count) {
@ -253,7 +252,7 @@ hasFoldingWin (
infop->fi_lnum = first; infop->fi_lnum = first;
infop->fi_low_level = low_level == 0 ? level + 1 : low_level; infop->fi_low_level = low_level == 0 ? level + 1 : low_level;
} }
return TRUE; return true;
} }
/* foldLevel() {{{2 */ /* foldLevel() {{{2 */

View File

@ -2120,12 +2120,12 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
* might be displayed differently. * might be displayed differently.
* Set w_cline_folded here as an efficient way to update it when * Set w_cline_folded here as an efficient way to update it when
* inserting lines just above a closed fold. */ * inserting lines just above a closed fold. */
i = hasFoldingWin(wp, lnum, &lnum, NULL, FALSE, NULL); bool folded = hasFoldingWin(wp, lnum, &lnum, NULL, false, NULL);
if (wp->w_cursor.lnum == lnum) if (wp->w_cursor.lnum == lnum)
wp->w_cline_folded = (i == TRUE); wp->w_cline_folded = folded;
i = hasFoldingWin(wp, lnume, NULL, &lnume, FALSE, NULL); folded = hasFoldingWin(wp, lnume, NULL, &lnume, false, NULL);
if (wp->w_cursor.lnum == lnume) if (wp->w_cursor.lnum == lnume)
wp->w_cline_folded = (i == TRUE); wp->w_cline_folded = folded;
/* If the changed line is in a range of previously folded lines, /* If the changed line is in a range of previously folded lines,
* compare with the first line in that range. */ * compare with the first line in that range. */

View File

@ -596,12 +596,12 @@ static void curs_rows(win_T *wp)
else else
wp->w_cline_height = plines_win(wp, wp->w_cursor.lnum, TRUE); wp->w_cline_height = plines_win(wp, wp->w_cursor.lnum, TRUE);
wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum, wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum,
NULL, NULL, TRUE, NULL) == TRUE; NULL, NULL, TRUE, NULL);
} else if (i > wp->w_lines_valid) { } else if (i > wp->w_lines_valid) {
/* a line that is too long to fit on the last screen line */ /* a line that is too long to fit on the last screen line */
wp->w_cline_height = 0; wp->w_cline_height = 0;
wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum, wp->w_cline_folded = hasFoldingWin(wp, wp->w_cursor.lnum,
NULL, NULL, TRUE, NULL) == TRUE; NULL, NULL, TRUE, NULL);
} else { } else {
wp->w_cline_height = wp->w_lines[i].wl_size; wp->w_cline_height = wp->w_lines[i].wl_size;
wp->w_cline_folded = wp->w_lines[i].wl_folded == TRUE; wp->w_cline_folded = wp->w_lines[i].wl_folded == TRUE;

View File

@ -4673,7 +4673,7 @@ void win_new_height(win_T *wp, int height)
set_topline(wp, lnum); set_topline(wp, lnum);
} else if (sline > 0) { } else if (sline > 0) {
while (sline > 0 && lnum > 1) { while (sline > 0 && lnum > 1) {
hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); (void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
if (lnum == 1) { if (lnum == 1) {
/* first line in buffer is folded */ /* first line in buffer is folded */
line_size = 1; line_size = 1;
@ -4694,7 +4694,7 @@ void win_new_height(win_T *wp, int height)
* Line we want at top would go off top of screen. Use next * Line we want at top would go off top of screen. Use next
* line instead. * line instead.
*/ */
hasFoldingWin(wp, lnum, NULL, &lnum, TRUE, NULL); (void)hasFoldingWin(wp, lnum, NULL, &lnum, true, NULL);
lnum++; lnum++;
wp->w_wrow -= line_size + sline; wp->w_wrow -= line_size + sline;
} else if (sline > 0) { } else if (sline > 0) {