mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1089: range count in user command
Problem: Cannot get range count in user command.
Solution: Add <range> argument.
c168bd4bd3
close #8946
This commit is contained in:
parent
ea5337d9b5
commit
d0c8dfc578
@ -1365,6 +1365,8 @@ The valid escape sequences are
|
|||||||
<line1> The starting line of the command range.
|
<line1> The starting line of the command range.
|
||||||
*<line2>*
|
*<line2>*
|
||||||
<line2> The final line of the command range.
|
<line2> The final line of the command range.
|
||||||
|
*<range>*
|
||||||
|
<range> The number of items in the command range: 0, 1 or 2
|
||||||
*<count>*
|
*<count>*
|
||||||
<count> Any count supplied (as described for the '-range'
|
<count> Any count supplied (as described for the '-range'
|
||||||
and '-count' attributes).
|
and '-count' attributes).
|
||||||
|
@ -5188,9 +5188,10 @@ static void ex_command(exarg_T *eap)
|
|||||||
while (*p == '-') {
|
while (*p == '-') {
|
||||||
++p;
|
++p;
|
||||||
end = skiptowhite(p);
|
end = skiptowhite(p);
|
||||||
if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl, &compl_arg, &addr_type_arg)
|
if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl, &compl_arg,
|
||||||
== FAIL)
|
&addr_type_arg) == FAIL) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
p = skipwhite(end);
|
p = skipwhite(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5221,9 +5222,10 @@ static void ex_command(exarg_T *eap)
|
|||||||
|| (name_len <= 4 && STRNCMP(name, "Next", name_len) == 0)) {
|
|| (name_len <= 4 && STRNCMP(name, "Next", name_len) == 0)) {
|
||||||
EMSG(_("E841: Reserved name, cannot be used for user defined command"));
|
EMSG(_("E841: Reserved name, cannot be used for user defined command"));
|
||||||
return;
|
return;
|
||||||
} else
|
} else {
|
||||||
uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
|
uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
|
||||||
addr_type_arg, eap->forceit);
|
addr_type_arg, eap->forceit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -5397,8 +5399,18 @@ uc_check_code(
|
|||||||
char_u *p = code + 1;
|
char_u *p = code + 1;
|
||||||
size_t l = len - 2;
|
size_t l = len - 2;
|
||||||
int quote = 0;
|
int quote = 0;
|
||||||
enum { ct_ARGS, ct_BANG, ct_COUNT, ct_LINE1, ct_LINE2, ct_MODS,
|
enum {
|
||||||
ct_REGISTER, ct_LT, ct_NONE } type = ct_NONE;
|
ct_ARGS,
|
||||||
|
ct_BANG,
|
||||||
|
ct_COUNT,
|
||||||
|
ct_LINE1,
|
||||||
|
ct_LINE2,
|
||||||
|
ct_RANGE,
|
||||||
|
ct_MODS,
|
||||||
|
ct_REGISTER,
|
||||||
|
ct_LT,
|
||||||
|
ct_NONE
|
||||||
|
} type = ct_NONE;
|
||||||
|
|
||||||
if ((vim_strchr((char_u *)"qQfF", *p) != NULL) && p[1] == '-') {
|
if ((vim_strchr((char_u *)"qQfF", *p) != NULL) && p[1] == '-') {
|
||||||
quote = (*p == 'q' || *p == 'Q') ? 1 : 2;
|
quote = (*p == 'q' || *p == 'Q') ? 1 : 2;
|
||||||
@ -5419,6 +5431,8 @@ uc_check_code(
|
|||||||
type = ct_LINE1;
|
type = ct_LINE1;
|
||||||
} else if (STRNICMP(p, "line2>", l) == 0) {
|
} else if (STRNICMP(p, "line2>", l) == 0) {
|
||||||
type = ct_LINE2;
|
type = ct_LINE2;
|
||||||
|
} else if (STRNICMP(p, "range>", l) == 0) {
|
||||||
|
type = ct_RANGE;
|
||||||
} else if (STRNICMP(p, "lt>", l) == 0) {
|
} else if (STRNICMP(p, "lt>", l) == 0) {
|
||||||
type = ct_LT;
|
type = ct_LT;
|
||||||
} else if (STRNICMP(p, "reg>", l) == 0 || STRNICMP(p, "register>", l) == 0) {
|
} else if (STRNICMP(p, "reg>", l) == 0 || STRNICMP(p, "register>", l) == 0) {
|
||||||
@ -5506,11 +5520,13 @@ uc_check_code(
|
|||||||
|
|
||||||
case ct_LINE1:
|
case ct_LINE1:
|
||||||
case ct_LINE2:
|
case ct_LINE2:
|
||||||
|
case ct_RANGE:
|
||||||
case ct_COUNT:
|
case ct_COUNT:
|
||||||
{
|
{
|
||||||
char num_buf[20];
|
char num_buf[20];
|
||||||
long num = (type == ct_LINE1) ? eap->line1 :
|
long num = (type == ct_LINE1) ? eap->line1 :
|
||||||
(type == ct_LINE2) ? eap->line2 :
|
(type == ct_LINE2) ? eap->line2 :
|
||||||
|
(type == ct_RANGE) ? eap->addr_count :
|
||||||
(eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
|
(eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
|
||||||
size_t num_len;
|
size_t num_len;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user