Skip to content

Commit c168bd4

Browse files
committed
patch 8.0.1089: cannot get range count in user command
Problem: Cannot get range count in user command. Solution: Add <range> argument.
1 parent 414168d commit c168bd4

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

runtime/doc/map.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,8 @@ The valid escape sequences are
14151415
<line1> The starting line of the command range.
14161416
*<line2>*
14171417
<line2> The final line of the command range.
1418+
*<range>*
1419+
<range> The number of items in the command range: 0, 1 or 2
14181420
*<count>*
14191421
<count> Any count supplied (as described for the '-range'
14201422
and '-count' attributes).

src/ex_docmd.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6331,7 +6331,8 @@ ex_command(exarg_T *eap)
63316331
{
63326332
++p;
63336333
end = skiptowhite(p);
6334-
if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl, &compl_arg, &addr_type_arg)
6334+
if (uc_scan_attr(p, end - p, &argt, &def, &flags, &compl,
6335+
&compl_arg, &addr_type_arg)
63356336
== FAIL)
63366337
return;
63376338
p = skipwhite(end);
@@ -6372,7 +6373,7 @@ ex_command(exarg_T *eap)
63726373
}
63736374
else
63746375
uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg,
6375-
addr_type_arg, eap->forceit);
6376+
addr_type_arg, eap->forceit);
63766377
}
63776378

63786379
/*
@@ -6592,8 +6593,18 @@ uc_check_code(
65926593
char_u *p = code + 1;
65936594
size_t l = len - 2;
65946595
int quote = 0;
6595-
enum { ct_ARGS, ct_BANG, ct_COUNT, ct_LINE1, ct_LINE2, ct_MODS,
6596-
ct_REGISTER, ct_LT, ct_NONE } type = ct_NONE;
6596+
enum {
6597+
ct_ARGS,
6598+
ct_BANG,
6599+
ct_COUNT,
6600+
ct_LINE1,
6601+
ct_LINE2,
6602+
ct_RANGE,
6603+
ct_MODS,
6604+
ct_REGISTER,
6605+
ct_LT,
6606+
ct_NONE
6607+
} type = ct_NONE;
65976608

65986609
if ((vim_strchr((char_u *)"qQfF", *p) != NULL) && p[1] == '-')
65996610
{
@@ -6615,6 +6626,8 @@ uc_check_code(
66156626
type = ct_LINE1;
66166627
else if (STRNICMP(p, "line2>", l) == 0)
66176628
type = ct_LINE2;
6629+
else if (STRNICMP(p, "range>", l) == 0)
6630+
type = ct_RANGE;
66186631
else if (STRNICMP(p, "lt>", l) == 0)
66196632
type = ct_LT;
66206633
else if (STRNICMP(p, "reg>", l) == 0 || STRNICMP(p, "register>", l) == 0)
@@ -6716,11 +6729,13 @@ uc_check_code(
67166729

67176730
case ct_LINE1:
67186731
case ct_LINE2:
6732+
case ct_RANGE:
67196733
case ct_COUNT:
67206734
{
67216735
char num_buf[20];
67226736
long num = (type == ct_LINE1) ? eap->line1 :
67236737
(type == ct_LINE2) ? eap->line2 :
6738+
(type == ct_RANGE) ? eap->addr_count :
67246739
(eap->addr_count > 0) ? eap->line2 : cmd->uc_def;
67256740
size_t num_len;
67266741

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1089,
772774
/**/
773775
1088,
774776
/**/

0 commit comments

Comments
 (0)