feat(column)!: rework 'statuscolumn' %r/l items

Problem:  A custom 'statuscolumn' needs to check a bunch of options and
          placed signs to replicate the default number column.
Solution: Rework %l item to include the necessary logic to mimic the
          default number column. Remove now redundant %r item.
This commit is contained in:
Luuk van Baal
2024-06-15 05:46:43 +02:00
parent 114197517f
commit ad70c9892d
10 changed files with 251 additions and 202 deletions

View File

@@ -587,12 +587,13 @@ static void draw_statuscol(win_T *wp, winlinevars_T *wlv, linenr_T lnum, int vir
char buf[MAXPATHL];
// When a buffer's line count has changed, make a best estimate for the full
// width of the status column by building with "w_nrwidth_line_count". Add
// potentially truncated width and rebuild before drawing anything.
// width of the status column by building with the largest possible line number.
// Add potentially truncated width and rebuild before drawing anything.
if (wp->w_statuscol_line_count != wp->w_nrwidth_line_count) {
wp->w_statuscol_line_count = wp->w_nrwidth_line_count;
set_vim_var_nr(VV_VIRTNUM, 0);
int width = build_statuscol_str(wp, wp->w_nrwidth_line_count, 0, buf, stcp);
int width = build_statuscol_str(wp, wp->w_nrwidth_line_count,
wp->w_nrwidth_line_count, buf, stcp);
if (width > stcp->width) {
int addwidth = MIN(width - stcp->width, MAX_STCWIDTH - stcp->width);
wp->w_nrwidth += addwidth;