1
0
forked from aniani/vim

patch 8.1.0658: deleting signs and completion for :sign is insufficient

Problem:    Deleting signs and completion for :sign is insufficient.
Solution:   Add deleting signs in a specified or any group from the current
            cursor location.  Add group and priority to sign command
            completion. Add tests for different sign unplace commands. Update
            help text.  Add tests for sign jump with group. Update help for
            sign jump. (Yegappan Lakshmanan, closes #3731)
This commit is contained in:
Bram Moolenaar
2018-12-29 18:53:55 +01:00
parent 01e51e5b30
commit 7d83bf4f2b
9 changed files with 506 additions and 148 deletions

View File

@@ -7895,7 +7895,7 @@ sign_place(
* Unplace the specified sign
*/
int
sign_unplace(int sign_id, char_u *sign_group, buf_T *buf)
sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T atlnum)
{
if (sign_id == 0)
{
@@ -7908,15 +7908,29 @@ sign_unplace(int sign_id, char_u *sign_group, buf_T *buf)
linenr_T lnum;
// Delete only the specified signs
lnum = buf_delsign(buf, sign_id, sign_group);
lnum = buf_delsign(buf, atlnum, sign_id, sign_group);
if (lnum == 0)
return FAIL;
update_debug_sign(buf, lnum);
}
return OK;
}
/*
* Unplace the sign at the current cursor line.
*/
static void
sign_unplace_at_cursor(char_u *groupname)
{
int id = -1;
id = buf_findsign_id(curwin->w_buffer, curwin->w_cursor.lnum, groupname);
if (id > 0)
sign_unplace(id, groupname, curwin->w_buffer, curwin->w_cursor.lnum);
else
EMSG(_("E159: Missing sign number"));
}
/*
* ":sign" command
*/
@@ -8047,14 +8061,8 @@ ex_sign(exarg_T *eap)
sign_list_placed(NULL, NULL);
}
else if (idx == SIGNCMD_UNPLACE)
{
/* ":sign unplace": remove placed sign at cursor */
id = buf_findsign_id(curwin->w_buffer, curwin->w_cursor.lnum);
if (id > 0)
sign_unplace(id, NULL, curwin->w_buffer);
else
EMSG(_("E159: Missing sign number"));
}
sign_unplace_at_cursor(NULL);
else
EMSG(_(e_argreq));
return;
@@ -8063,7 +8071,7 @@ ex_sign(exarg_T *eap)
if (idx == SIGNCMD_UNPLACE && arg[0] == '*' && arg[1] == NUL)
{
/* ":sign unplace *": remove all placed signs */
buf_delete_all_signs();
buf_delete_all_signs(NULL);
return;
}
@@ -8084,7 +8092,7 @@ ex_sign(exarg_T *eap)
{
/* ":sign unplace {id}": remove placed sign by number */
FOR_ALL_BUFFERS(buf)
sign_unplace(id, NULL, buf);
sign_unplace(id, NULL, buf, 0);
return;
}
}
@@ -8183,7 +8191,8 @@ ex_sign(exarg_T *eap)
}
else if (idx == SIGNCMD_JUMP)
{
/* ":sign jump {id} file={fname}" */
// ":sign jump {id} file={fname}"
// ":sign jump {id} group={group} file={fname}"
if (lnum >= 0 || sign_name != NULL || buf == NULL)
EMSG(_(e_invarg));
else if ((lnum = buf_findsign(buf, id, group)) > 0)
@@ -8225,7 +8234,7 @@ ex_sign(exarg_T *eap)
{
if (buf != NULL)
// ":sign unplace * file={fname}"
sign_unplace(0, group, buf);
sign_unplace(0, group, buf, 0);
else
// ":sign unplace * group=*": remove all placed signs
FOR_ALL_BUFFERS(buf)
@@ -8238,14 +8247,26 @@ ex_sign(exarg_T *eap)
// ":sign unplace {id} file={fname}"
// ":sign unplace {id} group={group} file={fname}"
// ":sign unplace {id} group=* file={fname}"
sign_unplace(id, group, buf);
sign_unplace(id, group, buf, 0);
else
// ":sign unplace {id} group={group}":
// ":sign unplace {id} group=*":
// remove all placed signs in this group.
FOR_ALL_BUFFERS(buf)
if (buf->b_signlist != NULL)
sign_unplace(id, group, buf);
{
if (id == -1)
{
// ":sign unplace group={group}":
// ":sign unplace group=*":
// remove sign in the current line in specified group
sign_unplace_at_cursor(group);
}
else
{
// ":sign unplace {id} group={group}":
// ":sign unplace {id} group=*":
// remove all placed signs in this group.
FOR_ALL_BUFFERS(buf)
if (buf->b_signlist != NULL)
sign_unplace(id, group, buf, 0);
}
}
}
}
/* idx == SIGNCMD_PLACE */
@@ -8581,13 +8602,14 @@ get_sign_name(expand_T *xp UNUSED, int idx)
{
char *place_arg[] =
{
"line=", "name=", "file=", "buffer=", NULL
"line=", "name=", "group=", "priority=", "file=",
"buffer=", NULL
};
return (char_u *)place_arg[idx];
}
case EXP_UNPLACE:
{
char *unplace_arg[] = { "file=", "buffer=", NULL };
char *unplace_arg[] = { "group=", "file=", "buffer=", NULL };
return (char_u *)unplace_arg[idx];
}
case EXP_SIGN_NAMES: