mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
fix(column): add truncated width during estimation for 'statuscolumn'
Problem: Estimated 'statuscolumn' width estimated is not properly used, executing the `w_redr_statuscol` path unnecessarily. Solution: Adjust `w_nrwidth` and 'statuscolumn' width before anything is actually drawn in a `win_update()`.
This commit is contained in:
parent
1013aba462
commit
cdc028e97d
@ -656,7 +656,15 @@ static void get_statuscol_str(win_T *wp, linenr_T lnum, int virtnum, statuscol_T
|
||||
wp->w_statuscol_line_count = wp->w_nrwidth_line_count;
|
||||
set_vim_var_nr(VV_VIRTNUM, 0);
|
||||
build_statuscol_str(wp, wp->w_nrwidth_line_count, 0, stcp);
|
||||
stcp->width += stcp->truncate;
|
||||
if (stcp->truncate > 0) {
|
||||
// Add truncated width to avoid unnecessary redraws
|
||||
int addwidth = MIN(stcp->truncate, MAX_NUMBERWIDTH - wp->w_nrwidth);
|
||||
stcp->truncate = 0;
|
||||
stcp->width += addwidth;
|
||||
wp->w_nrwidth += addwidth;
|
||||
wp->w_nrwidth_width = wp->w_nrwidth;
|
||||
wp->w_valid &= ~VALID_WCOL;
|
||||
}
|
||||
}
|
||||
set_vim_var_nr(VV_VIRTNUM, virtnum);
|
||||
|
||||
|
@ -616,4 +616,17 @@ describe('statuscolumn', function()
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it("is only evaluated twice, once to estimate and once to draw", function()
|
||||
command([[
|
||||
let g:stcnr = 0
|
||||
func! Stc()
|
||||
let g:stcnr += 1
|
||||
return '12345'
|
||||
endfunc
|
||||
set stc=%!Stc()
|
||||
norm ggdG
|
||||
]])
|
||||
eq(2, eval('g:stcnr'))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user