diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-01-18 14:56:33 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2024-01-18 16:12:57 +0000 |
commit | 7be20acf259ee9e97c407d794ce80ae3bf79cc49 (patch) | |
tree | aadee6616f10f7b0b74050a32776e2c61a30d3b5 /src | |
parent | 1c54cadba57ac248ea4fea7bf38c0f1a57c739a0 (diff) | |
download | rneovim-7be20acf259ee9e97c407d794ce80ae3bf79cc49.tar.gz rneovim-7be20acf259ee9e97c407d794ce80ae3bf79cc49.tar.bz2 rneovim-7be20acf259ee9e97c407d794ce80ae3bf79cc49.zip |
refactor(drawline): get_rightmost_vcol()
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/drawline.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 0bafbffdbf..cead63b88d 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -901,6 +901,26 @@ static void fix_for_boguscols(winlinevars_T *wlv) wlv->boguscols = 0; } +static int get_rightmost_vcol(win_T *wp, const int *color_cols) +{ + int ret = 0; + + if (wp->w_p_cuc) { + ret = wp->w_virtcol; + } + + if (color_cols) { + // determine rightmost colorcolumn to possibly draw + for (int i = 0; color_cols[i] >= 0; i++) { + if (ret < color_cols[i]) { + ret = color_cols[i]; + } + } + } + + return ret; +} + /// Display line "lnum" of window "wp" on the screen. /// wp->w_virtcol needs to be valid. /// @@ -2521,21 +2541,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s && lnum != wp->w_cursor.lnum) || wlv.color_cols || wlv.line_attr_lowprio || wlv.line_attr || wlv.diff_hlf != 0 || has_virttext)) { - int rightmost_vcol = 0; - - if (wp->w_p_cuc) { - rightmost_vcol = wp->w_virtcol; - } - - if (wlv.color_cols) { - // determine rightmost colorcolumn to possibly draw - for (int i = 0; wlv.color_cols[i] >= 0; i++) { - if (rightmost_vcol < wlv.color_cols[i]) { - rightmost_vcol = wlv.color_cols[i]; - } - } - } - + int rightmost_vcol = get_rightmost_vcol(wp, wlv.color_cols); const int cuc_attr = win_hl_attr(wp, HLF_CUC); const int mc_attr = win_hl_attr(wp, HLF_MC); |