diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-02 08:31:04 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-02 08:44:42 -0400 |
commit | 3de785e7b58e4d99e02382881767934efcd0f82c (patch) | |
tree | f3e994b4753566a8aca998c84c7176735db9c475 | |
parent | d2c1d9c466b1154afa47befef019439a241810c3 (diff) | |
download | rneovim-3de785e7b58e4d99e02382881767934efcd0f82c.tar.gz rneovim-3de785e7b58e4d99e02382881767934efcd0f82c.tar.bz2 rneovim-3de785e7b58e4d99e02382881767934efcd0f82c.zip |
fold: add const to hasFoldingWin() variables
cache is bool so update callers to pass true/false, not TRUE/FALSE.
-rw-r--r-- | src/nvim/diff.c | 4 | ||||
-rw-r--r-- | src/nvim/fold.c | 23 | ||||
-rw-r--r-- | src/nvim/screen.c | 44 |
3 files changed, 37 insertions, 34 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index cc4bc1da6a..8699c16351 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1486,7 +1486,7 @@ int diff_check(win_T *wp, linenr_T lnum) } // 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; } @@ -1793,7 +1793,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin) check_topfill(towin, false); (void)hasFoldingWin(towin, towin->w_topline, &towin->w_topline, - NULL, TRUE, NULL); + NULL, true, NULL); } /// This is called when 'diffopt' is changed. diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 6cf29a56f0..37a6bdad69 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -147,29 +147,27 @@ int hasAnyFolding(win_T *win) */ 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 */ bool hasFoldingWin( - win_T *win, - linenr_T lnum, - linenr_T *firstp, - linenr_T *lastp, - int cache, /* when TRUE: use cached values of window */ - foldinfo_T *infop /* where to store fold info */ + win_T *const win, + const linenr_T lnum, + linenr_T *const firstp, + linenr_T *const lastp, + const bool cache, // when true: use cached values of window + foldinfo_T *const infop // where to store fold info ) { bool had_folded = false; linenr_T first = 0; linenr_T last = 0; linenr_T lnum_rel = lnum; - int x; fold_T *fp; int level = 0; bool use_level = false; bool maybe_small = false; - garray_T *gap; int low_level = 0; checkupdate(win); @@ -187,7 +185,7 @@ bool hasFoldingWin( * 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. */ - x = find_wl_entry(win, lnum); + const int x = find_wl_entry(win, lnum); if (x >= 0) { first = win->w_lines[x].wl_lnum; last = win->w_lines[x].wl_lastlnum; @@ -199,7 +197,7 @@ bool hasFoldingWin( /* * Recursively search for a fold that contains "lnum". */ - gap = &win->w_folds; + garray_T *gap = &win->w_folds; for (;; ) { if (!foldFind(gap, lnum_rel, &fp)) break; @@ -296,8 +294,9 @@ long foldedCount(win_T *win, linenr_T lnum, foldinfo_T *infop) { 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 0; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index be45c1573c..24ea221c78 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -783,16 +783,18 @@ static void win_update(win_T *wp) } } - (void)hasFoldingWin(wp, mod_top, &mod_top, NULL, TRUE, NULL); - if (mod_top > lnumt) + (void)hasFoldingWin(wp, mod_top, &mod_top, NULL, true, NULL); + if (mod_top > lnumt) { mod_top = lnumt; + } - /* Now do the same for the bottom line (one above mod_bot). */ - --mod_bot; - (void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, TRUE, NULL); - ++mod_bot; - if (mod_bot < lnumb) + // Now do the same for the bottom line (one above mod_bot). + mod_bot--; + (void)hasFoldingWin(wp, mod_bot, NULL, &mod_bot, true, NULL); + mod_bot++; + if (mod_bot < lnumb) { mod_bot = lnumb; + } } /* When a change starts above w_topline and the end is below @@ -876,7 +878,7 @@ static void win_update(win_T *wp) ++j; if (j >= wp->w_height - 2) break; - (void)hasFoldingWin(wp, ln, NULL, &ln, TRUE, NULL); + (void)hasFoldingWin(wp, ln, NULL, &ln, true, NULL); } } else 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 * rows, and may insert/delete lines */ j = idx; - for (l = lnum; l < mod_bot; ++l) { - if (hasFoldingWin(wp, l, NULL, &l, TRUE, NULL)) - ++new_rows; - else if (l == wp->w_topline) - new_rows += plines_win_nofill(wp, l, TRUE) - + wp->w_topfill; - else - new_rows += plines_win(wp, l, TRUE); - ++j; + for (l = lnum; l < mod_bot; l++) { + if (hasFoldingWin(wp, l, NULL, &l, true, NULL)) { + new_rows++; + } else if (l == wp->w_topline) { + new_rows += plines_win_nofill(wp, l, true) + wp->w_topfill; + } else { + new_rows += plines_win(wp, l, true); + } + j++; if (new_rows > wp->w_height - row - 2) { /* it's getting too much, must redraw the rest */ new_rows = 9999; @@ -5525,10 +5527,12 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum) && re_multiline(shl->rm.regprog)) { if (shl->first_lnum == 0) { for (shl->first_lnum = lnum; - shl->first_lnum > wp->w_topline; --shl->first_lnum) - if (hasFoldingWin(wp, shl->first_lnum - 1, - NULL, NULL, TRUE, NULL)) + shl->first_lnum > wp->w_topline; + shl->first_lnum--) { + if (hasFoldingWin(wp, shl->first_lnum - 1, NULL, NULL, true, NULL)) { break; + } + } } if (cur != NULL) { cur->pos.cur = 0; |