diff options
author | James McCoy <jamessan@jamessan.com> | 2019-12-15 21:17:16 -0500 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2019-12-15 21:17:16 -0500 |
commit | 6566251d144d2c9c9e08e05c8c3a3fe9915a19b8 (patch) | |
tree | 980fd0c7287e295c8ac72858b0794f72224415e0 /src/nvim/misc1.c | |
parent | 9c4223215f71e1212462ada4e698be1b31437dd9 (diff) | |
parent | 9f3d483c79f03c48239fdc82cc02e8685a03d22a (diff) | |
download | rneovim-6566251d144d2c9c9e08e05c8c3a3fe9915a19b8.tar.gz rneovim-6566251d144d2c9c9e08e05c8c3a3fe9915a19b8.tar.bz2 rneovim-6566251d144d2c9c9e08e05c8c3a3fe9915a19b8.zip |
Merge remote-tracking branch 'upstream/master' into libcall
Diffstat (limited to 'src/nvim/misc1.c')
-rw-r--r-- | src/nvim/misc1.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index ab3520dd73..a871d424c6 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -30,7 +30,6 @@ #include "nvim/indent_c.h" #include "nvim/buffer_updates.h" #include "nvim/main.h" -#include "nvim/mark.h" #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" @@ -484,25 +483,39 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column) return lines; } +/// Get the number of screen lines lnum takes up. This takes care of +/// both folds and topfill, and limits to the current window height. +/// +/// @param[in] wp window line is in +/// @param[in] lnum line number +/// @param[out] nextp if not NULL, the line after a fold +/// @param[out] foldedp if not NULL, whether lnum is on a fold +/// @param[in] cache whether to use the window's cache for folds +/// +/// @return the total number of screen lines +int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp, + bool *const foldedp, const bool cache) +{ + bool folded = hasFoldingWin(wp, lnum, NULL, nextp, cache, NULL); + if (foldedp) { + *foldedp = folded; + } + if (folded) { + return 1; + } else if (lnum == wp->w_topline) { + return plines_win_nofill(wp, lnum, true) + wp->w_topfill; + } + return plines_win(wp, lnum, true); +} + int plines_m_win(win_T *wp, linenr_T first, linenr_T last) { int count = 0; while (first <= last) { - // Check if there are any really folded lines, but also included lines - // that are maybe folded. - linenr_T x = foldedCount(wp, first, NULL); - if (x > 0) { - ++count; /* count 1 for "+-- folded" line */ - first += x; - } else { - if (first == wp->w_topline) { - count += plines_win_nofill(wp, first, true) + wp->w_topfill; - } else { - count += plines_win(wp, first, true); - } - first++; - } + linenr_T next = first; + count += plines_win_full(wp, first, &next, NULL, false); + first = next + 1; } return count; } |