aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-01-02 04:06:18 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-01-02 12:20:35 -0500
commit215aa83b2af85939900739a94f0d4d00902a2fed (patch)
tree0669fc5c8632c2e74ac7d617fb5b44a341de44b5
parentcb5ba225f870d421fb83b49c360218e9be34a80d (diff)
downloadrneovim-215aa83b2af85939900739a94f0d4d00902a2fed.tar.gz
rneovim-215aa83b2af85939900739a94f0d4d00902a2fed.tar.bz2
rneovim-215aa83b2af85939900739a94f0d4d00902a2fed.zip
vim-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. https://github.com/vim/vim/commit/0acae7acc40b9f12bff88d5e1dae494a761fec07
-rw-r--r--src/nvim/ex_docmd.c25
-rw-r--r--src/nvim/globals.h1
-rw-r--r--src/nvim/testdir/test_excmd.vim11
3 files changed, 28 insertions, 9 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 397157f238..ccf7dd0f68 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -3729,6 +3729,15 @@ char_u *skip_range(
return (char_u *)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
//
// Set ptr to the next character after the part that was interpreted.
@@ -3778,10 +3787,10 @@ static linenr_T get_address(exarg_T *eap,
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;
@@ -3823,10 +3832,10 @@ static linenr_T get_address(exarg_T *eap,
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;
@@ -3851,7 +3860,7 @@ static linenr_T get_address(exarg_T *eap,
goto error;
}
if (addr_type != ADDR_LINES) {
- EMSG(_(e_invaddr));
+ addr_error(addr_type);
cmd = NULL;
goto error;
}
@@ -3879,7 +3888,7 @@ static linenr_T get_address(exarg_T *eap,
case '?': /* '/' or '?' - search */
c = *cmd++;
if (addr_type != ADDR_LINES) {
- EMSG(_(e_invaddr));
+ addr_error(addr_type);
cmd = NULL;
goto error;
}
@@ -3926,7 +3935,7 @@ static linenr_T get_address(exarg_T *eap,
case '\\': /* "\?", "\/" or "\&", repeat search */
++cmd;
if (addr_type != ADDR_LINES) {
- EMSG(_(e_invaddr));
+ addr_error(addr_type);
cmd = NULL;
goto error;
}
@@ -7863,7 +7872,7 @@ static void ex_copymove(exarg_T *eap)
* move or copy lines from 'eap->line1'-'eap->line2' to below line 'n'
*/
if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) {
- EMSG(_(e_invaddr));
+ EMSG(_(e_invrange));
return;
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 31b905e858..3b8f4116b7 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -866,7 +866,6 @@ EXTERN char_u e_failed[] INIT(= N_("E472: Command failed"));
EXTERN char_u e_internal[] INIT(= N_("E473: Internal error"));
EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s"));
EXTERN char_u e_interr[] INIT(= N_("Interrupted"));
-EXTERN char_u e_invaddr[] INIT(= N_("E14: Invalid address"));
EXTERN char_u e_invarg[] INIT(= N_("E474: Invalid argument"));
EXTERN char_u e_invarg2[] INIT(= N_("E475: Invalid argument: %s"));
EXTERN char_u e_invargval[] INIT(= N_("E475: Invalid value for argument %s"));
diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim
index 4a027c3864..8606564d29 100644
--- a/src/nvim/testdir/test_excmd.vim
+++ b/src/nvim/testdir/test_excmd.vim
@@ -9,6 +9,17 @@ func Test_ex_delete()
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
+
func Test_buffers_lastused()
edit bufc " oldest