diff options
-rw-r--r-- | src/nvim/api/vim.c | 6 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/misc1.c | 8 | ||||
-rw-r--r-- | src/nvim/mouse.c | 14 | ||||
-rw-r--r-- | src/nvim/move.c | 37 | ||||
-rw-r--r-- | src/nvim/normal.c | 8 | ||||
-rw-r--r-- | src/nvim/screen.c | 4 |
8 files changed, 41 insertions, 42 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 58ee53a408..400dbb126c 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -2301,7 +2301,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, } } } - ParserLine plines[] = { + ParserLine parser_lines[] = { { .data = expr.data, .size = expr.size, @@ -2309,7 +2309,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, }, { NULL, 0, false }, }; - ParserLine *plines_p = plines; + ParserLine *plines_p = parser_lines; ParserHighlight colors; kvi_init(colors); ParserHighlight *const colors_p = (highlight ? &colors : NULL); @@ -2335,7 +2335,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, ret.items[ret.size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("len"), .value = INTEGER_OBJ((Integer)(pstate.pos.line == 1 - ? plines[0].size + ? parser_lines[0].size : pstate.pos.col)), }; if (east.err.msg != NULL) { diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 3db6892b71..ec6d5a3955 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -1298,7 +1298,7 @@ struct window_S { /* * w_cline_height is the number of physical lines taken by the buffer line - * that the cursor is on. We use this to avoid extra calls to plines(). + * that the cursor is on. We use this to avoid extra calls to plines_win(). */ int w_cline_height; // current size of cursor line bool w_cline_folded; // cursor line is folded diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2b3d773ca4..af8a23f5cc 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2593,7 +2593,7 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline, ColoredCmdline *const ret_ccline_colors) FUNC_ATTR_NONNULL_ALL { - ParserLine plines[] = { + ParserLine parser_lines[] = { { .data = (const char *)colored_ccline->cmdbuff, .size = STRLEN(colored_ccline->cmdbuff), @@ -2601,7 +2601,7 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline, }, { NULL, 0, false }, }; - ParserLine *plines_p = plines; + ParserLine *plines_p = parser_lines; ParserHighlight colors; kvi_init(colors); ParserState pstate; diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 771174b854..9487df3d8f 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -349,14 +349,6 @@ int get_last_leader_offset(char_u *line, char_u **flags) return result; } -/* - * Return the number of window lines occupied by buffer line "lnum". - */ -int plines(const linenr_T lnum) -{ - return plines_win(curwin, lnum, true); -} - int plines_win( win_T *const wp, const linenr_T lnum, diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index f1ad0ed105..f4da43007d 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -236,12 +236,14 @@ retnomove: if (row < 0) { count = 0; for (first = true; curwin->w_topline > 1; ) { - if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) - ++count; - else - count += plines(curwin->w_topline - 1); - if (!first && count > -row) + if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) { + count++; + } else { + count += plines_win(curwin, curwin->w_topline - 1, true); + } + if (!first && count > -row) { break; + } first = false; (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL); if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) { @@ -262,7 +264,7 @@ retnomove: if (curwin->w_topfill > 0) { ++count; } else { - count += plines(curwin->w_topline); + count += plines_win(curwin, curwin->w_topline, true); } if (!first && count > row - curwin->w_height_inner + 1) { diff --git a/src/nvim/move.c b/src/nvim/move.c index 293f51f2d9..48ac3a02a3 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1090,8 +1090,9 @@ bool scrolldown(long line_count, int byfold) curwin->w_cursor.lnum = 1; else curwin->w_cursor.lnum = first - 1; - } else - wrow -= plines(curwin->w_cursor.lnum--); + } else { + wrow -= plines_win(curwin, curwin->w_cursor.lnum--, true); + } curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL); moved = true; @@ -1425,11 +1426,12 @@ void scroll_cursor_top(int min_scroll, int always) : plines_nofill(top); used += i; if (extra + i <= off && bot < curbuf->b_ml.ml_line_count) { - if (hasFolding(bot, NULL, &bot)) - /* count one logical line for a sequence of folded lines */ - ++used; - else - used += plines(bot); + if (hasFolding(bot, NULL, &bot)) { + // count one logical line for a sequence of folded lines + used++; + } else { + used += plines_win(curwin, bot, true); + } } if (used > curwin->w_height_inner) { break; @@ -1809,11 +1811,12 @@ void cursor_correct(void) int below = curwin->w_filler_rows; /* screen lines below botline */ while ((above < above_wanted || below < below_wanted) && topline < botline) { if (below < below_wanted && (below <= above || above >= above_wanted)) { - if (hasFolding(botline, &botline, NULL)) - ++below; - else - below += plines(botline); - --botline; + if (hasFolding(botline, &botline, NULL)) { + below++; + } else { + below += plines_win(curwin, botline, true); + } + botline--; } if (above < above_wanted && (above < below || below >= below_wanted)) { if (hasFolding(topline, NULL, &topline)) @@ -2146,12 +2149,12 @@ void halfpage(bool flag, linenr_T Prenum) else { room += i; do { - i = plines(curwin->w_botline); - if (i > room) + i = plines_win(curwin, curwin->w_botline, true); + if (i > room) { break; - (void)hasFolding(curwin->w_botline, NULL, - &curwin->w_botline); - ++curwin->w_botline; + } + (void)hasFolding(curwin->w_botline, NULL, &curwin->w_botline); + curwin->w_botline++; room -= i; } while (curwin->w_botline <= curbuf->b_ml.ml_line_count); } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 54ca216a53..eb680203f7 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5122,11 +5122,13 @@ static void nv_scroll(cmdarg_T *cap) --n; break; } - used += plines(curwin->w_topline + n); - if (used >= half) + used += plines_win(curwin, curwin->w_topline + n, true); + if (used >= half) { break; - if (hasFolding(curwin->w_topline + n, NULL, &lnum)) + } + if (hasFolding(curwin->w_topline + n, NULL, &lnum)) { n = lnum - curwin->w_topline; + } } if (n > 0 && used > curwin->w_height_inner) { n--; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2fc5777937..7292229c0a 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1694,7 +1694,7 @@ static void win_update(win_T *wp, Providers *providers) /* * There is a trick with w_botline. If we invalidate it on each * change that might modify it, this will cause a lot of expensive - * calls to plines() in update_topline() each time. Therefore the + * calls to plines_win() in update_topline() each time. Therefore the * value of w_botline is often approximated, and this value is used to * compute the value of w_topline. If the value of w_botline was * wrong, check that the value of w_topline is correct (cursor is on @@ -4119,7 +4119,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, /* * Update w_cline_height and w_cline_folded if the cursor line was - * updated (saves a call to plines() later). + * updated (saves a call to plines_win() later). */ if (wp == curwin && lnum == curwin->w_cursor.lnum) { curwin->w_cline_row = startrow; |