aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2023-12-30 02:57:57 +0100
committerGitHub <noreply@github.com>2023-12-30 09:57:57 +0800
commitdd00b6b442a6d3a8a4758b0ee10ac93d07e7db72 (patch)
tree2fdcaea0f1ab92cadefc22a9df828f092c43fe9a
parentc5e9acca6471280e32fbcaa30849aa68358155ca (diff)
downloadrneovim-dd00b6b442a6d3a8a4758b0ee10ac93d07e7db72.tar.gz
rneovim-dd00b6b442a6d3a8a4758b0ee10ac93d07e7db72.tar.bz2
rneovim-dd00b6b442a6d3a8a4758b0ee10ac93d07e7db72.zip
refactor(drawline): remove maybe_wlv argument for foldcolumn (#26798)
Problem: fill_foldcolumn() has an optional winlinevars_T argument. Solution: Increment wlv->off at callsite.
-rw-r--r--src/nvim/drawline.c32
-rw-r--r--src/nvim/statusline.c2
2 files changed, 14 insertions, 20 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 0e2f0e95ea..4b14a3a1ee 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -388,7 +388,9 @@ static void draw_foldcolumn(win_T *wp, winlinevars_T *wlv)
int fdc = compute_foldcolumn(wp, 0);
if (fdc > 0) {
int attr = win_hl_attr(wp, use_cursor_line_highlight(wp, wlv->lnum) ? HLF_CLF : HLF_FC);
- fill_foldcolumn(wlv, wp, wlv->foldinfo, wlv->lnum, attr, fdc, NULL);
+ fill_foldcolumn(wp, wlv->foldinfo, wlv->lnum, attr, fdc, NULL);
+ assert(wlv->off == 0);
+ wlv->off = fdc;
}
}
@@ -396,23 +398,23 @@ static void draw_foldcolumn(win_T *wp, winlinevars_T *wlv)
///
/// @param fdc Current width of the foldcolumn
/// @param[out] out_buffer Char array to write into, only used for 'statuscolumn'
-void fill_foldcolumn(void *maybe_wlv, win_T *wp, foldinfo_T foldinfo, linenr_T lnum, int attr,
- int fdc, schar_T *out_buffer)
+void fill_foldcolumn(win_T *wp, foldinfo_T foldinfo, linenr_T lnum, int attr, int fdc,
+ schar_T *out_buffer)
{
bool closed = foldinfo.fi_level != 0 && foldinfo.fi_lines > 0;
int level = foldinfo.fi_level;
- winlinevars_T *wlv = maybe_wlv; // TODO(bfredl): this is bullshit
-
// If the column is too narrow, we start at the lowest level that
// fits and use numbers to indicate the depth.
int first_level = MAX(level - fdc - closed + 1, 1);
- int endcol = MIN(fdc, level);
+ int closedcol = MIN(fdc, level);
int i = 0;
- for (i = 0; i < endcol; i++) {
+ for (i = 0; i < fdc; i++) {
int symbol = 0;
- if (i == endcol - 1 && closed) {
+ if (i >= level) {
+ symbol = ' ';
+ } else if (i == closedcol - 1 && closed) {
symbol = wp->w_p_fcs_chars.foldclosed;
} else if (foldinfo.fi_lnum == lnum && first_level + i >= foldinfo.fi_low_level) {
symbol = wp->w_p_fcs_chars.foldopen;
@@ -427,19 +429,11 @@ void fill_foldcolumn(void *maybe_wlv, win_T *wp, foldinfo_T foldinfo, linenr_T l
if (out_buffer) {
out_buffer[i] = schar_from_char(symbol);
} else {
- linebuf_vcol[wlv->off] = (i == endcol - 1 && closed) ? -2 : -3;
- linebuf_attr[wlv->off] = attr;
- linebuf_char[wlv->off++] = schar_from_char(symbol);
+ linebuf_vcol[i] = i >= level ? -1 : (i == closedcol - 1 && closed) ? -2 : -3;
+ linebuf_attr[i] = attr;
+ linebuf_char[i] = schar_from_char(symbol);
}
}
-
- if (out_buffer) {
- while (i < fdc) {
- out_buffer[i++] = schar_from_ascii(' ');
- }
- } else {
- draw_col_fill(wlv, schar_from_ascii(' '), fdc - i, attr);
- }
}
/// Get information needed to display the sign in line "wlv->lnum" in window "wp".
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index 1843676820..baf5318c76 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -1642,7 +1642,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, OptIndex op
char *p = NULL;
if (fold) {
schar_T fold_buf[10];
- fill_foldcolumn(NULL, wp, stcp->foldinfo,
+ fill_foldcolumn(wp, stcp->foldinfo,
(linenr_T)get_vim_var_nr(VV_LNUM), 0, fdc, fold_buf);
stl_items[curitem].minwid = -((stcp->use_cul ? HLF_CLF : HLF_FC) + 1);
size_t buflen = 0;