fix(column): fix wrong cursor with 'statuscolumn' and cpo+=n (#24268)

This commit is contained in:
zeertzjq
2023-07-06 11:07:23 +08:00
committed by GitHub
parent a0c9c04f00
commit 25e62697c3
3 changed files with 64 additions and 5 deletions

View File

@@ -748,7 +748,7 @@ static void get_statuscol_display_info(statuscol_T *stcp, winlinevars_T *wlv)
// Skip over empty highlight sections
} while (wlv->n_extra == 0 && stcp->textp < stcp->text_end);
if (wlv->n_extra > 0) {
static char transbuf[MAX_NUMBERWIDTH * MB_MAXBYTES + 1];
static char transbuf[(MAX_NUMBERWIDTH + 9 + 9 * 2) * MB_MAXBYTES + 1];
wlv->n_extra = (int)transstr_buf(wlv->p_extra, wlv->n_extra, transbuf, sizeof transbuf, true);
wlv->p_extra = transbuf;
}

View File

@@ -775,9 +775,9 @@ void validate_cursor_col(void)
// fold column and sign column (these don't move when scrolling horizontally).
int win_col_off(win_T *wp)
{
return ((wp->w_p_nu || wp->w_p_rnu || (*wp->w_p_stc != NUL)) ?
return ((wp->w_p_nu || wp->w_p_rnu || *wp->w_p_stc != NUL) ?
(number_width(wp) + (*wp->w_p_stc == NUL)) : 0)
+ (cmdwin_type == 0 || wp != curwin ? 0 : 1)
+ ((cmdwin_type == 0 || wp != curwin) ? 0 : 1)
+ win_fdccol_count(wp)
+ (win_signcol_count(wp) * win_signcol_width(wp));
}
@@ -792,8 +792,9 @@ int curwin_col_off(void)
// is in 'cpoptions'.
int win_col_off2(win_T *wp)
{
if ((wp->w_p_nu || wp->w_p_rnu) && vim_strchr(p_cpo, CPO_NUMCOL) != NULL) {
return number_width(wp) + 1;
if ((wp->w_p_nu || wp->w_p_rnu || *wp->w_p_stc != NUL)
&& vim_strchr(p_cpo, CPO_NUMCOL) != NULL) {
return number_width(wp) + (*wp->w_p_stc == NUL);
}
return 0;
}