diff options
author | Matthieu Coudron <mattator@gmail.com> | 2020-04-27 13:53:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-27 13:53:41 +0200 |
commit | d90a92bcd3c18111abb62a57192c9e151839a7f4 (patch) | |
tree | e9b9163c0896aa099f7c543c76197d28dbfdc5d3 /src/nvim/screen.c | |
parent | fc98f2d5815d8f7e671766db255edbb7365960b1 (diff) | |
parent | fcd9ce39012c9328b999c4ccb7eaa7c22766168e (diff) | |
download | rneovim-d90a92bcd3c18111abb62a57192c9e151839a7f4.tar.gz rneovim-d90a92bcd3c18111abb62a57192c9e151839a7f4.tar.bz2 rneovim-d90a92bcd3c18111abb62a57192c9e151839a7f4.zip |
Merge pull request #12018 from janlazo/vim-8.0.1123
[RFC]vim-patch:8.0.{1123,1125,1138,1139,1142,1292,1334,1375},8.1.1264
Diffstat (limited to 'src/nvim/screen.c')
-rw-r--r-- | src/nvim/screen.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 9c590efdbc..45c56549c5 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1741,6 +1741,31 @@ static int advance_color_col(int vcol, int **color_cols) return **color_cols >= 0; } +// Returns the next grid column. +static int text_to_screenline(win_T *wp, char_u *text, int col, int off) + FUNC_ATTR_NONNULL_ALL +{ + int idx = wp->w_p_rl ? off : off + col; + LineState s = LINE_STATE(text); + + while (*s.p != NUL) { + // TODO(bfredl): cargo-culted from the old Vim code: + // if(col + cells > wp->w_width - (wp->w_p_rl ? col : 0)) { break; } + // This is obvious wrong. If Vim ever fixes this, solve for "cells" again + // in the correct condition. + const int maxcells = wp->w_grid.Columns - col - (wp->w_p_rl ? col : 0); + const int cells = line_putchar(&s, &linebuf_char[idx], maxcells, + wp->w_p_rl); + if (cells == -1) { + break; + } + col += cells; + idx += cells; + } + + return col; +} + // Compute the width of the foldcolumn. Based on 'foldcolumn' and how much // space is available for window "wp", minus "col". static int compute_foldcolumn(win_T *wp, int col) @@ -1942,29 +1967,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T // 5. move the text to linebuf_char[off]. Fill up with "fold". // Right-left text is put in columns 0 - number-col, normal text is put // in columns number-col - window-width. - int idx; - - if (wp->w_p_rl) { - idx = off; - } else { - idx = off + col; - } - - LineState s = LINE_STATE(text); - - while (*s.p != NUL) { - // TODO(bfredl): cargo-culted from the old Vim code: - // if(col + cells > wp->w_width - (wp->w_p_rl ? col : 0)) { break; } - // This is obvious wrong. If Vim ever fixes this, solve for "cells" again - // in the correct condition. - int maxcells = wp->w_grid.Columns - col - (wp->w_p_rl ? col : 0); - int cells = line_putchar(&s, &linebuf_char[idx], maxcells, wp->w_p_rl); - if (cells == -1) { - break; - } - col += cells; - idx += cells; - } + col = text_to_screenline(wp, text, col, off); /* Fill the rest of the line with the fold filler */ if (wp->w_p_rl) |