neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 7be20acf259ee9e97c407d794ce80ae3bf79cc49
parent 1c54cadba57ac248ea4fea7bf38c0f1a57c739a0
Author: Lewis Russell <lewis6991@gmail.com>
Date:   Thu, 18 Jan 2024 14:56:33 +0000

refactor(drawline): get_rightmost_vcol()

Diffstat:
Msrc/nvim/drawline.c | 36+++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)

diff --git 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);