0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

patch 8.1.0709: windows are updated for every added/deleted sign

Problem:    Windows are updated for every added/deleted sign.
Solution:   Do not call update_debug_sign().  Only redraw when the line with
            the sign is visible.  (idea from neovim #9479)
This commit is contained in:
Bram Moolenaar
2019-01-09 21:47:30 +01:00
parent ae12f4bad3
commit 27a472c32e
4 changed files with 41 additions and 42 deletions

View File

@@ -5,6 +5,7 @@ void redraw_later_clear(void);
void redraw_all_later(int type); void redraw_all_later(int type);
void redraw_curbuf_later(int type); void redraw_curbuf_later(int type);
void redraw_buf_later(buf_T *buf, int type); void redraw_buf_later(buf_T *buf, int type);
void redraw_buf_line_later(buf_T *buf, linenr_T lnum);
void redraw_buf_and_status_later(buf_T *buf, int type); void redraw_buf_and_status_later(buf_T *buf, int type);
int redraw_asap(int type); int redraw_asap(int type);
void redraw_after_callback(int call_update_screen); void redraw_after_callback(int call_update_screen);

View File

@@ -263,6 +263,17 @@ redraw_buf_later(buf_T *buf, int type)
} }
} }
void
redraw_buf_line_later(buf_T *buf, linenr_T lnum)
{
win_T *wp;
FOR_ALL_WINDOWS(wp)
if (wp->w_buffer == buf && lnum >= wp->w_topline
&& lnum < wp->w_botline)
redrawWinline(wp, lnum);
}
void void
redraw_buf_and_status_later(buf_T *buf, int type) redraw_buf_and_status_later(buf_T *buf, int type)
{ {
@@ -978,26 +989,13 @@ update_debug_sign(buf_T *buf, linenr_T lnum)
win_foldinfo.fi_level = 0; win_foldinfo.fi_level = 0;
# endif # endif
/* update/delete a specific mark */ // update/delete a specific sign
redraw_buf_line_later(buf, lnum);
// check if it resulted in the need to redraw a window
FOR_ALL_WINDOWS(wp) FOR_ALL_WINDOWS(wp)
{
if (buf != NULL && lnum > 0)
{
if (wp->w_buffer == buf && lnum >= wp->w_topline
&& lnum < wp->w_botline)
{
if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum)
wp->w_redraw_top = lnum;
if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum)
wp->w_redraw_bot = lnum;
redraw_win_later(wp, VALID);
}
}
else
redraw_win_later(wp, VALID);
if (wp->w_redr_type != 0) if (wp->w_redr_type != 0)
doit = TRUE; doit = TRUE;
}
/* Return when there is nothing to do, screen updating is already /* Return when there is nothing to do, screen updating is already
* happening (recursive call), messages on the screen or still starting up. * happening (recursive call), messages on the screen or still starting up.

View File

@@ -327,8 +327,8 @@ buf_addsign(
prev = NULL; prev = NULL;
FOR_ALL_SIGNS_IN_BUF(buf, sign) FOR_ALL_SIGNS_IN_BUF(buf, sign)
{ {
if (lnum == sign->lnum && id == sign->id && if (lnum == sign->lnum && id == sign->id
sign_in_group(sign, groupname)) && sign_in_group(sign, groupname))
{ {
// Update an existing sign // Update an existing sign
sign->typenr = typenr; sign->typenr = typenr;
@@ -427,9 +427,9 @@ buf_delsign(
for (sign = buf->b_signlist; sign != NULL; sign = next) for (sign = buf->b_signlist; sign != NULL; sign = next)
{ {
next = sign->next; next = sign->next;
if ((id == 0 || sign->id == id) && if ((id == 0 || sign->id == id)
(atlnum == 0 || sign->lnum == atlnum) && && (atlnum == 0 || sign->lnum == atlnum)
sign_in_group(sign, group)) && sign_in_group(sign, group))
{ {
*lastp = next; *lastp = next;
@@ -439,7 +439,8 @@ buf_delsign(
if (sign->group != NULL) if (sign->group != NULL)
sign_group_unref(sign->group->sg_name); sign_group_unref(sign->group->sg_name);
vim_free(sign); vim_free(sign);
update_debug_sign(buf, lnum); redraw_buf_line_later(buf, lnum);
// Check whether only one sign needs to be deleted // Check whether only one sign needs to be deleted
// If deleting a sign with a specific identifer in a particular // If deleting a sign with a specific identifer in a particular
// group or deleting any sign at a particular line number, delete // group or deleting any sign at a particular line number, delete
@@ -453,13 +454,10 @@ buf_delsign(
lastp = &sign->next; lastp = &sign->next;
} }
// When deleted the last sign need to redraw the windows to remove the // When deleting the last sign the cursor position may change, because the
// sign column. // sign columns no longer shows.
if (buf->b_signlist == NULL) if (buf->b_signlist == NULL)
{
redraw_buf_later(buf, NOT_VALID);
changed_cline_bef_curs(); changed_cline_bef_curs();
}
return lnum; return lnum;
} }
@@ -932,7 +930,7 @@ sign_place(
// ":sign place {id} file={fname}": change sign type // ":sign place {id} file={fname}": change sign type
lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr); lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr);
if (lnum > 0) if (lnum > 0)
update_debug_sign(buf, lnum); redraw_buf_line_later(buf, lnum);
else else
{ {
EMSG2(_("E885: Not possible to change sign %s"), sign_name); EMSG2(_("E885: Not possible to change sign %s"), sign_name);
@@ -1068,8 +1066,8 @@ sign_place_cmd(
// :sign place // :sign place
// :sign place group={group} // :sign place group={group}
// :sign place group=* // :sign place group=*
if (lnum >= 0 || sign_name != NULL || if (lnum >= 0 || sign_name != NULL
(group != NULL && *group == '\0')) || (group != NULL && *group == '\0'))
EMSG(_(e_invarg)); EMSG(_(e_invarg));
else else
sign_list_placed(buf, group); sign_list_placed(buf, group);
@@ -1077,8 +1075,8 @@ sign_place_cmd(
else else
{ {
// Place a new sign // Place a new sign
if (sign_name == NULL || buf == NULL || if (sign_name == NULL || buf == NULL
(group != NULL && *group == '\0')) || (group != NULL && *group == '\0'))
{ {
EMSG(_(e_invarg)); EMSG(_(e_invarg));
return; return;
@@ -1174,8 +1172,8 @@ sign_jump_cmd(
return; return;
} }
if (buf == NULL || (group != NULL && *group == '\0') || if (buf == NULL || (group != NULL && *group == '\0')
lnum >= 0 || sign_name != NULL) || lnum >= 0 || sign_name != NULL)
{ {
// File or buffer is not specified or an empty group is used // File or buffer is not specified or an empty group is used
// or a line number or a sign name is specified. // or a line number or a sign name is specified.
@@ -1330,7 +1328,7 @@ parse_sign_cmd_args(
// If the filename is not supplied for the sign place or the sign jump // If the filename is not supplied for the sign place or the sign jump
// command, then use the current buffer. // command, then use the current buffer.
if (filename == NULL && ((cmd == SIGNCMD_PLACE && lnum_arg) if (filename == NULL && ((cmd == SIGNCMD_PLACE && lnum_arg)
|| cmd == SIGNCMD_JUMP)) || cmd == SIGNCMD_JUMP))
*buf = curwin->w_buffer; *buf = curwin->w_buffer;
return OK; return OK;
@@ -1522,10 +1520,10 @@ sign_get_placed_in_buf(
{ {
if (!sign_in_group(sign, sign_group)) if (!sign_in_group(sign, sign_group))
continue; continue;
if ((lnum == 0 && sign_id == 0) || if ((lnum == 0 && sign_id == 0)
(sign_id == 0 && lnum == sign->lnum) || || (sign_id == 0 && lnum == sign->lnum)
(lnum == 0 && sign_id == sign->id) || || (lnum == 0 && sign_id == sign->id)
(lnum == sign->lnum && sign_id == sign->id)) || (lnum == sign->lnum && sign_id == sign->id))
{ {
if ((sdict = sign_get_info(sign)) != NULL) if ((sdict = sign_get_info(sign)) != NULL)
list_append_dict(l, sdict); list_append_dict(l, sdict);
@@ -1864,8 +1862,8 @@ set_context_in_sign_cmd(expand_T *xp, char_u *arg)
switch (cmd_idx) switch (cmd_idx)
{ {
case SIGNCMD_DEFINE: case SIGNCMD_DEFINE:
if (STRNCMP(last, "texthl", p - last) == 0 || if (STRNCMP(last, "texthl", p - last) == 0
STRNCMP(last, "linehl", p - last) == 0) || STRNCMP(last, "linehl", p - last) == 0)
xp->xp_context = EXPAND_HIGHLIGHT; xp->xp_context = EXPAND_HIGHLIGHT;
else if (STRNCMP(last, "icon", p - last) == 0) else if (STRNCMP(last, "icon", p - last) == 0)
xp->xp_context = EXPAND_FILES; xp->xp_context = EXPAND_FILES;

View File

@@ -799,6 +799,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
709,
/**/ /**/
708, 708,
/**/ /**/