summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-12-29 18:53:55 +0100
committerBram Moolenaar <Bram@vim.org>2018-12-29 18:53:55 +0100
commit7d83bf4f2b785b46d87c7bc376fc9d0a862af782 (patch)
tree0676cfef64951ed975c086173f1099998b7dfb94 /src/ex_cmds.c
parent01e51e5b305c13c68b5ea2b9e14779e1e88664ef (diff)
patch 8.1.0658: deleting signs and completion for :sign is insufficientv8.1.0658
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)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c68
1 files changed, 45 insertions, 23 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 6a79451061..b5ad3b3564 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -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,16 +7908,30 @@ 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
*/
void
@@ -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: