Mercurial > vim
changeset 17650:a1437b8f2fac v8.1.1822
patch 8.1.1822: confusing error message when range is not allowed
commit https://github.com/vim/vim/commit/0acae7acc40b9f12bff88d5e1dae494a761fec07
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 6 21:29:29 2019 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 06 Aug 2019 21:30:06 +0200 |
parents | 221733de15e7 |
children | 826360df7aff |
files | src/ex_docmd.c src/globals.h src/testdir/test_excmd.vim src/version.c |
diffstat | 4 files changed, 30 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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_NONE: case ADDR_TABS_RELATIVE: - case ADDR_NONE: 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_NONE: case ADDR_TABS_RELATIVE: - case ADDR_NONE: 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; }
--- a/src/globals.h +++ b/src/globals.h @@ -1456,7 +1456,6 @@ EXTERN char e_fontwidth[] INIT(= N_("E23 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"));
--- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -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