diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-09-10 17:34:35 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-09-10 17:34:35 +0200 |
commit | c168bd4bd3a9b856fc410fc4515dcca1d10d7461 (patch) | |
tree | 03b405fbbad695745400ace91e3d1a0ed8275364 | |
parent | 414168d97fad45387a3d7dd16449d15b27079ad8 (diff) |
patch 8.0.1089: cannot get range count in user commandv8.0.1089
Problem: Cannot get range count in user command.
Solution: Add <range> argument.
-rw-r--r-- | runtime/doc/map.txt | 2 | ||||
-rw-r--r-- | src/ex_docmd.c | 23 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 23 insertions, 4 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 983fb2db4d..f6bcde2377 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1415,6 +1415,8 @@ The valid escape sequences are <line1> The starting line of the command range. *<line2>* <line2> The final line of the command range. + *<range>* + <range> The number of items in the command range: 0, 1 or 2 *<count>* <count> Any count supplied (as described for the '-range' and '-count' attributes). diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 0bcb7fec50..33f544437e 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -6331,7 +6331,8 @@ ex_command(exarg_T *eap) { ++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, &addr_type_arg) == FAIL) return; p = skipwhite(end); @@ -6372,7 +6373,7 @@ ex_command(exarg_T *eap) } else uc_add_command(name, end - name, p, argt, def, flags, compl, compl_arg, - addr_type_arg, eap->forceit); + addr_type_arg, eap->forceit); } /* @@ -6592,8 +6593,18 @@ uc_check_code( char_u *p = code + 1; size_t l = len - 2; int quote = 0; - enum { ct_ARGS, ct_BANG, ct_COUNT, ct_LINE1, ct_LINE2, ct_MODS, - ct_REGISTER, ct_LT, ct_NONE } type = ct_NONE; + enum { + 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] == '-') { @@ -6615,6 +6626,8 @@ uc_check_code( type = ct_LINE1; else if (STRNICMP(p, "line2>", l) == 0) type = ct_LINE2; + else if (STRNICMP(p, "range>", l) == 0) + type = ct_RANGE; else if (STRNICMP(p, "lt>", l) == 0) type = ct_LT; else if (STRNICMP(p, "reg>", l) == 0 || STRNICMP(p, "register>", l) == 0) @@ -6716,11 +6729,13 @@ uc_check_code( case ct_LINE1: case ct_LINE2: + case ct_RANGE: case ct_COUNT: { char num_buf[20]; long num = (type == ct_LINE1) ? eap->line1 : (type == ct_LINE2) ? eap->line2 : + (type == ct_RANGE) ? eap->addr_count : (eap->addr_count > 0) ? eap->line2 : cmd->uc_def; size_t num_len; diff --git a/src/version.c b/src/version.c index c86b7dc29d..b10216f697 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1089, +/**/ 1088, /**/ 1087, |