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.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index a656686a95..5b0418ed92 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -5,18 +5,18 @@
#include <assert.h>
#include <inttypes.h>
+#include <limits.h>
#include <stdbool.h>
#include <string.h>
-#include <limits.h>
-#include "nvim/vim.h"
#include "nvim/ascii.h"
-#include "nvim/plines.h"
+#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
+#include "nvim/decoration.h"
#include "nvim/diff.h"
-#include "nvim/func_attr.h"
#include "nvim/fold.h"
+#include "nvim/func_attr.h"
#include "nvim/indent.h"
#include "nvim/main.h"
#include "nvim/mbyte.h"
@@ -24,10 +24,11 @@
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
+#include "nvim/plines.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
+#include "nvim/vim.h"
#include "nvim/window.h"
-#include "nvim/buffer.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "plines.c.generated.h"
@@ -41,7 +42,34 @@ int plines_win(win_T *wp, linenr_T lnum, bool winheight)
{
// Check for filler lines above this buffer line. When folded the result
// is one line anyway.
- return plines_win_nofill(wp, lnum, winheight) + diff_check_fill(wp, lnum);
+ return plines_win_nofill(wp, lnum, winheight) + win_get_fill(wp, lnum);
+}
+
+
+/// Return the number of filler lines above "lnum".
+///
+/// @param wp
+/// @param lnum
+///
+/// @return Number of filler lines above lnum
+int win_get_fill(win_T *wp, linenr_T lnum)
+{
+ int virt_lines = decor_virtual_lines(wp, lnum);
+
+ // be quick when there are no filler lines
+ if (diffopt_filler()) {
+ int n = diff_check(wp, lnum);
+
+ if (n > 0) {
+ return virt_lines+n;
+ }
+ }
+ return virt_lines;
+}
+
+bool win_may_fill(win_T *wp)
+{
+ return (wp->w_p_diff && diffopt_filler()) || wp->w_buffer->b_virt_line_mark;
}
/// @param winheight when true limit to window height
@@ -71,7 +99,7 @@ int plines_win_nofill(win_T *wp, linenr_T lnum, bool winheight)
/// "wp". Does not care about folding, 'wrap' or 'diff'.
int plines_win_nofold(win_T *wp, linenr_T lnum)
{
- char_u *s;
+ char_u *s;
unsigned int col;
int width;
@@ -107,7 +135,7 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
{
// Check for filler lines above this buffer line. When folded the result
// is one line anyway.
- int lines = diff_check_fill(wp, lnum);
+ int lines = win_get_fill(wp, lnum);
if (!wp->w_p_wrap) {
return lines + 1;
@@ -159,8 +187,8 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
/// @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)
+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) {
@@ -302,8 +330,7 @@ int lbr_chartabsize_adv(char_u *line, char_u **s, colnr_T col)
/// @param headp
///
/// @return The number of characters taken up on the screen.
-int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
- colnr_T col, int *headp)
+int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *headp)
{
colnr_T col2;
colnr_T col_adj = 0; // col + screen size of tab
@@ -326,7 +353,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
int size = win_chartabsize(wp, s, col);
int c = *s;
if (*s == TAB) {
- col_adj = size - 1;
+ col_adj = size - 1;
}
// If 'linebreak' set check at a blank before a non-blank if the line
@@ -343,8 +370,8 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s,
colmax = (colnr_T)(wp->w_width_inner - numberextra - col_adj);
if (col >= colmax) {
- colmax += col_adj;
- n = colmax + win_col_off2(wp);
+ colmax += col_adj;
+ n = colmax + win_col_off2(wp);
if (n > 0) {
colmax += (((col - colmax) / n) + 1) * n - col_adj;