diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2021-09-05 17:45:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-05 17:45:46 +0200 |
commit | 7a0468e7addc8745d82abdfb62d25714f38dae8f (patch) | |
tree | e021094cf622d667becbe036b6ee6ee2ba78348b | |
parent | c9c9422af0671fea1a3967b98d4c8eef057b2e92 (diff) | |
parent | 274248c35475c08e4a9824e0002e7d0caaae81f7 (diff) | |
download | rneovim-7a0468e7addc8745d82abdfb62d25714f38dae8f.tar.gz rneovim-7a0468e7addc8745d82abdfb62d25714f38dae8f.tar.bz2 rneovim-7a0468e7addc8745d82abdfb62d25714f38dae8f.zip |
Merge pull request #15569 from bfredl/end_fill
refactor(screen): let win_line() always handle fillers after last line
-rw-r--r-- | src/nvim/fold.h | 2 | ||||
-rw-r--r-- | src/nvim/screen.c | 26 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src/nvim/fold.h b/src/nvim/fold.h index 95c4b0c1dc..37fab4da60 100644 --- a/src/nvim/fold.h +++ b/src/nvim/fold.h @@ -21,6 +21,8 @@ typedef struct foldinfo { long fi_lines; } foldinfo_T; +#define FOLDINFO_INIT { 0, 0, 0, 0 } + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "fold.h.generated.h" diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cfaa36bc15..5a995b9a40 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1695,17 +1695,11 @@ static void win_update(win_T *wp, Providers *providers) wp->w_botline = buf->b_ml.ml_line_count + 1; j = diff_check_fill(wp, wp->w_botline); if (j > 0 && !wp->w_botfill) { - // display filler lines at the end of the file - if (char2cells(wp->w_p_fcs_chars.diff) > 1) { - i = '-'; - } else { - i = wp->w_p_fcs_chars.diff; - } - if (row + j > wp->w_grid.Rows) { - j = wp->w_grid.Rows - row; - } - win_draw_end(wp, i, i, true, row, row + (int)j, HLF_DED); - row += j; + // Display filler text below last line. win_line() will check + // for ml_line_count+1 and only draw filler lines + foldinfo_T info = FOLDINFO_INIT; + row = win_line(wp, wp->w_botline, row, wp->w_grid.Rows, + false, false, info, &line_providers); } } else if (dollar_vcol == -1) { wp->w_botline = lnum; @@ -2196,6 +2190,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc row = startrow; buf_T *buf = wp->w_buffer; + bool end_fill = (lnum == buf->b_ml.ml_line_count+1); if (!number_only) { // To speed up the loop below, set extra_check when there is linebreak, @@ -2263,6 +2258,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc if (wp->w_p_spell && !has_fold + && !end_fill && *wp->w_s->b_p_spl != NUL && !GA_EMPTY(&wp->w_s->b_langp) && *(char **)(wp->w_s->b_langp.ga_data) != NULL) { @@ -2466,7 +2462,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc line_attr_lowprio_save = line_attr_lowprio; } - line = ml_get_buf(wp->w_buffer, lnum, false); + line = end_fill ? (char_u *)"" : ml_get_buf(wp->w_buffer, lnum, false); ptr = line; if (has_spell && !number_only) { @@ -2500,7 +2496,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } } - if (wp->w_p_list && !has_fold) { + if (wp->w_p_list && !has_fold && !end_fill) { if (wp->w_p_lcs_chars.space || wp->w_p_lcs_chars.trail || wp->w_p_lcs_chars.lead @@ -2656,7 +2652,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc cur = wp->w_match_head; shl_flag = false; while ((cur != NULL || !shl_flag) && !number_only - && !has_fold) { + && !has_fold && !end_fill) { if (!shl_flag) { shl = &search_hl; shl_flag = true; @@ -4467,7 +4463,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc filler_todo--; // When the filler lines are actually below the last line of the // file, don't draw the line itself, break here. - if (filler_todo == 0 && wp->w_botfill) { + if (filler_todo == 0 && (wp->w_botfill || end_fill)) { break; } } |