aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/plines.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/plines.c')
-rw-r--r--src/nvim/plines.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 4409b14ae1..e51e9bf8c3 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -712,7 +712,7 @@ bool win_may_fill(win_T *wp)
/// @return Number of filler lines above lnum
int win_get_fill(win_T *wp, linenr_T lnum)
{
- int virt_lines = decor_virt_lines(wp, lnum, NULL);
+ int virt_lines = decor_virt_lines(wp, lnum - 1, lnum, NULL, true);
// be quick when there are no filler lines
if (diffopt_filler()) {
@@ -906,6 +906,25 @@ int plines_m_win(win_T *wp, linenr_T first, linenr_T last, int max)
return MIN(max, count);
}
+/// Return number of window lines a physical line range will occupy.
+/// Only considers real and filler lines.
+///
+/// Mainly used for calculating scrolling offsets.
+int plines_m_win_fill(win_T *wp, linenr_T first, linenr_T last)
+{
+ int count = last - first + 1 + decor_virt_lines(wp, first - 1, last, NULL, false);
+
+ if (diffopt_filler()) {
+ for (int lnum = first; lnum <= last; lnum++) {
+ // Note: this also considers folds.
+ int n = diff_check(wp, lnum);
+ count += MAX(n, 0);
+ }
+ }
+
+ return MAX(count, 0);
+}
+
/// Get the number of screen lines a range of text will take in window "wp".
///
/// @param[in] start_lnum Starting line number, 1-based inclusive.