0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.1822: confusing error message when range is not allowed

Problem:    Confusing error message when range is not allowed.
Solution:   With ADDR_NONE give e_norange.  Change e_invaddr to e_invrange for
            consistency.
This commit is contained in:
Bram Moolenaar
2019-08-06 21:29:29 +02:00
parent f97d46f816
commit 0acae7acc4
4 changed files with 30 additions and 9 deletions

View File

@@ -4208,6 +4208,15 @@ skip_range(
return cmd;
}
static void
addr_error(cmd_addr_T addr_type)
{
if (addr_type == ADDR_NONE)
emsg(_(e_norange));
else
emsg(_(e_invrange));
}
/*
* Get a single EX address.
*
@@ -4264,10 +4273,10 @@ get_address(
case ADDR_TABS:
lnum = CURRENT_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
case ADDR_NONE:
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
emsg(_(e_invrange));
addr_error(addr_type);
cmd = NULL;
goto error;
break;
@@ -4314,10 +4323,10 @@ get_address(
case ADDR_TABS:
lnum = LAST_TAB_NR;
break;
case ADDR_TABS_RELATIVE:
case ADDR_NONE:
case ADDR_TABS_RELATIVE:
case ADDR_UNSIGNED:
emsg(_(e_invrange));
addr_error(addr_type);
cmd = NULL;
goto error;
break;
@@ -4346,7 +4355,7 @@ get_address(
}
if (addr_type != ADDR_LINES)
{
emsg(_(e_invaddr));
addr_error(addr_type);
cmd = NULL;
goto error;
}
@@ -4378,7 +4387,7 @@ get_address(
c = *cmd++;
if (addr_type != ADDR_LINES)
{
emsg(_(e_invaddr));
addr_error(addr_type);
cmd = NULL;
goto error;
}
@@ -4428,7 +4437,7 @@ get_address(
++cmd;
if (addr_type != ADDR_LINES)
{
emsg(_(e_invaddr));
addr_error(addr_type);
cmd = NULL;
goto error;
}
@@ -7926,7 +7935,7 @@ ex_copymove(exarg_T *eap)
*/
if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count)
{
emsg(_(e_invaddr));
emsg(_(e_invrange));
return;
}

View File

@@ -1456,7 +1456,6 @@ EXTERN char e_fontwidth[] INIT(= N_("E236: Font \"%s\" is not fixed-width"));
EXTERN char e_internal[] INIT(= N_("E473: Internal error"));
EXTERN char e_intern2[] INIT(= N_("E685: Internal error: %s"));
EXTERN char e_interr[] INIT(= N_("Interrupted"));
EXTERN char e_invaddr[] INIT(= N_("E14: Invalid address"));
EXTERN char e_invarg[] INIT(= N_("E474: Invalid argument"));
EXTERN char e_invarg2[] INIT(= N_("E475: Invalid argument: %s"));
EXTERN char e_duparg2[] INIT(= N_("E983: Duplicate argument: %s"));

View File

@@ -8,3 +8,14 @@ func Test_ex_delete()
.dl
call assert_equal(['a', 'c'], getline(1, 2))
endfunc
func Test_range_error()
call assert_fails(':.echo 1', 'E481:')
call assert_fails(':$echo 1', 'E481:')
call assert_fails(':1,2echo 1', 'E481:')
call assert_fails(':+1echo 1', 'E481:')
call assert_fails(':/1/echo 1', 'E481:')
call assert_fails(':\/echo 1', 'E481:')
normal vv
call assert_fails(":'<,'>echo 1", 'E481:')
endfunc

View File

@@ -773,6 +773,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1822,
/**/
1821,
/**/