Merge pull request #14391 from lewis6991/signs

signs: Change b_signcols_max -> b_signcols_valid
This commit is contained in:
Björn Linse 2021-07-04 23:16:49 +02:00 committed by GitHub
commit c6226bd6c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 14 deletions

View File

@ -1786,7 +1786,7 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum,
buf = xcalloc(1, sizeof(buf_T));
// init b: variables
buf->b_vars = tv_dict_alloc();
buf->b_signcols_max = -1;
buf->b_signcols_valid = false;
init_var_dict(buf->b_vars, &buf->b_bufvar, VAR_SCOPE);
buf_init_changedtick(buf);
}
@ -5547,16 +5547,16 @@ bool find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp)
int buf_signcols(buf_T *buf)
{
if (buf->b_signcols_max == -1) {
if (!buf->b_signcols_valid) {
sign_entry_T *sign; // a sign in the sign list
buf->b_signcols_max = 0;
int signcols = 0;
int linesum = 0;
linenr_T curline = 0;
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->se_lnum > curline) {
if (linesum > buf->b_signcols_max) {
buf->b_signcols_max = linesum;
if (linesum > signcols) {
signcols = linesum;
}
curline = sign->se_lnum;
linesum = 0;
@ -5565,15 +5565,17 @@ int buf_signcols(buf_T *buf)
linesum++;
}
}
if (linesum > buf->b_signcols_max) {
buf->b_signcols_max = linesum;
if (linesum > signcols) {
signcols = linesum;
}
// Check if we need to redraw
if (buf->b_signcols_max != buf->b_signcols) {
buf->b_signcols = buf->b_signcols_max;
if (signcols != buf->b_signcols) {
buf->b_signcols = signcols;
redraw_buf_later(buf, NOT_VALID);
}
buf->b_signcols_valid = true;
}
return buf->b_signcols;

View File

@ -849,8 +849,8 @@ struct file_buffer {
// may use a different synblock_T.
sign_entry_T *b_signlist; // list of placed signs
int b_signcols_max; // cached maximum number of sign columns
int b_signcols; // last calculated number of sign columns
bool b_signcols_valid; // calculated sign columns is valid
Terminal *terminal; // Terminal instance associated with the buffer

View File

@ -194,7 +194,7 @@ static void insert_sign(
if (next != NULL) {
next->se_prev = newsign;
}
buf->b_signcols_max = -1;
buf->b_signcols_valid = false;
if (prev == NULL) {
// When adding first sign need to redraw the windows to create the
@ -534,7 +534,7 @@ linenr_T buf_delsign(
sign_entry_T *next; // the next sign in a b_signlist
linenr_T lnum; // line number whose sign was deleted
buf->b_signcols_max = -1;
buf->b_signcols_valid = false;
lastp = &buf->b_signlist;
lnum = 0;
for (sign = buf->b_signlist; sign != NULL; sign = next) {
@ -668,7 +668,7 @@ void buf_delete_signs(buf_T *buf, char_u *group)
lastp = &sign->se_next;
}
}
buf->b_signcols_max = -1;
buf->b_signcols_valid = false;
}
/// List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers.
@ -735,7 +735,7 @@ void sign_mark_adjust(
int is_fixed = 0;
int signcol = win_signcol_configured(curwin, &is_fixed);
curbuf->b_signcols_max = -1;
curbuf->b_signcols_valid = false;
lastp = &curbuf->b_signlist;
for (sign = curbuf->b_signlist; sign != NULL; sign = next) {