mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(signcol): handle edge case with maximum value
50250542
failed to consider that the maximum passed to buf_signcols
is window scoped whereas the signcols value is buffer scoped. This can
lead to a bug where the signcolumn becomes incorrect if:
- global signcolumn is set to auto:N
- signcolumn in a window is changed locally to auto:M where M > N
- the buffer has a line with M or greater signs.
This commit is contained in:
parent
fdea15723f
commit
e67cd22c38
@ -5495,11 +5495,19 @@ static int buf_signcols_inner(buf_T *buf, int maximum)
|
||||
|
||||
int buf_signcols(buf_T *buf, int maximum)
|
||||
{
|
||||
// The maximum can be determined from 'signcolumn' which is window scoped so
|
||||
// need to invalidate signcols if the maximum is greater than the previous
|
||||
// maximum.
|
||||
if (maximum > buf->b_signcols_max) {
|
||||
buf->b_signcols_valid = false;
|
||||
}
|
||||
|
||||
if (!buf->b_signcols_valid) {
|
||||
int signcols = buf_signcols_inner(buf, maximum);
|
||||
// Check if we need to redraw
|
||||
if (signcols != buf->b_signcols) {
|
||||
buf->b_signcols = signcols;
|
||||
buf->b_signcols_max = maximum;
|
||||
redraw_buf_later(buf, NOT_VALID);
|
||||
}
|
||||
|
||||
|
@ -864,6 +864,7 @@ struct file_buffer {
|
||||
sign_entry_T *b_signlist; // list of placed signs
|
||||
int b_signcols; // last calculated number of sign columns
|
||||
bool b_signcols_valid; // calculated sign columns is valid
|
||||
int b_signcols_max; // Maximum value b_signcols is valid for.
|
||||
|
||||
Terminal *terminal; // Terminal instance associated with the buffer
|
||||
|
||||
|
@ -8165,7 +8165,7 @@ int win_signcol_configured(win_T *wp, int *is_fixed)
|
||||
}
|
||||
|
||||
int needed_signcols = buf_signcols(wp->w_buffer, maximum);
|
||||
int ret = MAX(minimum, needed_signcols);
|
||||
int ret = MAX(minimum, MIN(maximum, needed_signcols));
|
||||
assert(ret <= SIGN_SHOW_MAX);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user