-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
WIP: revisit dynamic signcolumn #9788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This goes well together with the previous commit. Vim uses this internally since it has a hard width of 2 cells for the signcolumn, but that has changed in Neovim now.
} | ||
} | ||
|
||
if (nr_signs > 0 && buf->b_signcols_max < same) { | ||
buf->b_signcols_max = same; | ||
buf->b_signcols_cells = cells; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop should be made clearer probably.
@@ -5899,7 +5899,7 @@ comp_textwidth ( | |||
textwidth -= 1; | |||
} | |||
textwidth -= curwin->w_p_fdc; | |||
textwidth -= win_signcol_count(curwin); | |||
textwidth -= win_signcol_width(curwin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should/could address the buffer value directly probably for performance reasons.
if (cells == 1) { | ||
STRCPY(sp->sn_text + len - 1, " "); | ||
} | ||
sp->sn_text = vim_strnsave(arg, p - arg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in a separate commit - not strictly necessary, but allows for having signs only take one cell after all.
@@ -3035,6 +3035,8 @@ did_set_string_option ( | |||
// 'signcolumn' | |||
if (check_opt_strings(*varp, p_scl_values, false) != OK) { | |||
errmsg = e_invarg; | |||
} else { | |||
curwin->w_buffer->b_signcols_max = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalidates the cache - could need a comment maybe. But it is done like this in many places already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably need #define SIGNCOLS_UNKNOWN -1
in sign_defs.h
by now.
src/nvim/option.c
Outdated
if (cols) { | ||
return MAX(cols, wp->w_buffer->b_signcols_cells); | ||
} | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was quick and dirty.
Any idea how to improve this? (not having two functions)
p_extra = extra; | ||
p_extra[n_extra] = NUL; | ||
n_extra = (int)STRLEN(p_extra); | ||
sign_cells -= mb_string2cells(p_extra); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -781,6 +781,7 @@ struct file_buffer { | |||
signlist_T *b_signlist; // list of signs to draw | |||
int b_signcols_max; // cached maximum number of sign columns | |||
int b_signcols; // last calculated number of sign columns | |||
int b_signcols_cells; // number of cells used for sign columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need another field (and thus all the associated housekeeping)? why can't this replace b_signcols
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count != cols, max/b_signcols holds the count.
https://github.com/blueyed/neovim/blob/6d5f8c7addcc4b276a436531e75cb3b620fe513e/src/nvim/buffer.c#L5163-L5167
But it certainly should at least use "cols" (effective).
I might be missing something here though.
cc @da-x |
So one test is failing, but I cannot reproduce it (likely because the real UI does not allow to move the cursor there?!):
|
This is meant to be more robust in case signs are not two chars long. (neovim/neovim#9788)
This is meant to be more robust in case signs are not two chars long. (neovim/neovim#9788)
Closing for now. |
No description provided.