mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #17472 from lewis6991/signcol_improvements
signcol improvements
This commit is contained in:
commit
8dd3d40f5c
@ -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
|
||||
|
||||
@ -1353,6 +1354,7 @@ struct window_S {
|
||||
// recomputed
|
||||
int w_nrwidth; // width of 'number' and 'relativenumber'
|
||||
// column being used
|
||||
int w_scwidth; // width of 'signcolumn'
|
||||
|
||||
/*
|
||||
* === end of cached values ===
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -326,6 +326,18 @@ void redraw_buf_status_later(buf_T *buf)
|
||||
}
|
||||
}
|
||||
|
||||
void redraw_win_signcol(win_T *wp)
|
||||
{
|
||||
// If we can compute a change in the automatic sizing of the sign column
|
||||
// under 'signcolumn=auto:X' and signs currently placed in the buffer, better
|
||||
// figuring it out here so we can redraw the entire screen for it.
|
||||
int scwidth = wp->w_scwidth;
|
||||
wp->w_scwidth = win_signcol_count(wp);
|
||||
if (wp->w_scwidth != scwidth) {
|
||||
changed_line_abv_curs_win(wp);
|
||||
}
|
||||
}
|
||||
|
||||
/// Redraw the parts of the screen that is marked for redraw.
|
||||
///
|
||||
/// Most code shouldn't call this directly, rather use redraw_later() and
|
||||
@ -790,12 +802,6 @@ static void win_update(win_T *wp, Providers *providers)
|
||||
linenr_T mod_bot = 0;
|
||||
int save_got_int;
|
||||
|
||||
|
||||
// If we can compute a change in the automatic sizing of the sign column
|
||||
// under 'signcolumn=auto:X' and signs currently placed in the buffer, better
|
||||
// figuring it out here so we can redraw the entire screen for it.
|
||||
win_signcol_count(wp);
|
||||
|
||||
type = wp->w_redr_type;
|
||||
|
||||
if (type >= NOT_VALID) {
|
||||
@ -817,6 +823,8 @@ static void win_update(win_T *wp, Providers *providers)
|
||||
return;
|
||||
}
|
||||
|
||||
redraw_win_signcol(wp);
|
||||
|
||||
init_search_hl(wp);
|
||||
|
||||
/* Force redraw when width of 'number' or 'relativenumber' column
|
||||
@ -1846,7 +1854,7 @@ static void win_draw_end(win_T *wp, int c1, int c2, bool draw_margin, int row, i
|
||||
win_hl_attr(wp, HLF_FC));
|
||||
}
|
||||
// draw the sign column
|
||||
int count = win_signcol_count(wp);
|
||||
int count = wp->w_scwidth;
|
||||
if (count > 0) {
|
||||
n = win_fill_end(wp, ' ', ' ', n, win_signcol_width(wp) * count, row,
|
||||
endrow, win_hl_attr(wp, HLF_SC));
|
||||
@ -2792,10 +2800,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
|
||||
draw_state = WL_SIGN;
|
||||
/* Show the sign column when there are any signs in this
|
||||
* buffer or when using Netbeans. */
|
||||
int count = win_signcol_count(wp);
|
||||
if (count > 0) {
|
||||
if (wp->w_scwidth > 0) {
|
||||
get_sign_display_info(false, wp, lnum, sattrs, row,
|
||||
startrow, filler_lines, filler_todo, count,
|
||||
startrow, filler_lines, filler_todo,
|
||||
&c_extra, &c_final, extra, sizeof(extra),
|
||||
&p_extra, &n_extra,
|
||||
&char_attr, &draw_state, &sign_idx);
|
||||
@ -2814,9 +2821,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
|
||||
// number.
|
||||
if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'
|
||||
&& num_signs > 0 && sign_get_attr(SIGN_TEXT, sattrs, 0, 1)) {
|
||||
int count = win_signcol_count(wp);
|
||||
get_sign_display_info(true, wp, lnum, sattrs, row,
|
||||
startrow, filler_lines, filler_todo, count,
|
||||
startrow, filler_lines, filler_todo,
|
||||
&c_extra, &c_final, extra, sizeof(extra),
|
||||
&p_extra, &n_extra,
|
||||
&char_attr, &draw_state, &sign_idx);
|
||||
@ -4674,10 +4680,11 @@ static bool use_cursor_line_sign(win_T *wp, linenr_T lnum)
|
||||
// @param[in, out] sign_idxp Index of the displayed sign
|
||||
static void get_sign_display_info(bool nrcol, win_T *wp, linenr_T lnum, sign_attrs_T sattrs[],
|
||||
int row, int startrow, int filler_lines, int filler_todo,
|
||||
int count, int *c_extrap, int *c_finalp, char_u *extra,
|
||||
int *c_extrap, int *c_finalp, char_u *extra,
|
||||
size_t extra_size, char_u **pp_extra, int *n_extrap,
|
||||
int *char_attrp, int *draw_statep, int *sign_idxp)
|
||||
{
|
||||
int count = wp->w_scwidth;
|
||||
// Draw cells with the sign value or blank.
|
||||
*c_extrap = ' ';
|
||||
*c_finalp = NUL;
|
||||
|
@ -446,7 +446,7 @@ describe('Signs', function()
|
||||
{1:>>>>>>>>}{6: 1 }a |
|
||||
{2: }{6: 2 }b |
|
||||
{2: }{6: 3 }c |
|
||||
{2: }{6:^ 4 } |
|
||||
{2: }{6: 4 }^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
@ -468,7 +468,7 @@ describe('Signs', function()
|
||||
{1:>>>>>>>>>>}{6: 1 }a |
|
||||
{2: }{6: 2 }b |
|
||||
{2: }{6: 3 }c |
|
||||
{2: ^ }{6: 4 } |
|
||||
{2: }{6: 4 }^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
@ -512,7 +512,7 @@ describe('Signs', function()
|
||||
{1:>>}{6: 1 }a |
|
||||
{2: }{6: 2 }b |
|
||||
{2: }{6: 3 }c |
|
||||
{2: }{6: ^4 } |
|
||||
{2: }{6: 4 }^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
Loading…
Reference in New Issue
Block a user