aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_docmd.c8
-rw-r--r--test/functional/ex_cmds/excmd_spec.lua8
-rw-r--r--test/old/testdir/test_excmd.vim7
3 files changed, 16 insertions, 7 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index f66464fa3a..63e7a80e53 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1411,7 +1411,11 @@ void set_cmd_count(exarg_T *eap, linenr_T count, bool validate)
}
} else {
eap->line1 = eap->line2;
- eap->line2 += count - 1;
+ if (eap->line2 >= INT32_MAX - (count - 1)) {
+ eap->line2 = INT32_MAX;
+ } else {
+ eap->line2 += count - 1;
+ }
eap->addr_count++;
// Be vi compatible: no error message for out of range.
if (validate && eap->line2 > curbuf->b_ml.ml_line_count) {
@@ -1429,7 +1433,7 @@ static int parse_count(exarg_T *eap, const char **errormsg, bool validate)
if ((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg)
&& (!(eap->argt & EX_BUFNAME) || *(p = skipdigits(eap->arg + 1)) == NUL
|| ascii_iswhite(*p))) {
- linenr_T n = getdigits_int32(&eap->arg, false, -1);
+ linenr_T n = getdigits_int32(&eap->arg, false, INT32_MAX);
eap->arg = skipwhite(eap->arg);
if (eap->args != NULL) {
diff --git a/test/functional/ex_cmds/excmd_spec.lua b/test/functional/ex_cmds/excmd_spec.lua
index 20ebb2dedb..923bb99eeb 100644
--- a/test/functional/ex_cmds/excmd_spec.lua
+++ b/test/functional/ex_cmds/excmd_spec.lua
@@ -29,13 +29,13 @@ describe('Ex cmds', function()
':tabnext 9999999999999999999999999999999999999999',
'Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999'
)
- check_excmd_err(
- ':N 9999999999999999999999999999999999999999',
- 'Vim(Next):E939: Positive count required'
+ eq(
+ 'Vim(Next):E163: There is only one file to edit',
+ pcall_err(command, ':N 9999999999999999999999999999999999999999')
)
check_excmd_err(
':bdelete 9999999999999999999999999999999999999999',
- 'Vim(bdelete):E939: Positive count required'
+ 'Vim(bdelete):E516: No buffers were deleted'
)
eq(
'Vim(menu):E329: No menu "9999999999999999999999999999999999999999"',
diff --git a/test/old/testdir/test_excmd.vim b/test/old/testdir/test_excmd.vim
index c8ddaa90fd..d900207928 100644
--- a/test/old/testdir/test_excmd.vim
+++ b/test/old/testdir/test_excmd.vim
@@ -722,9 +722,14 @@ func Test_address_line_overflow()
throw 'Skipped: only works with 64 bit long ints'
endif
new
- call setline(1, 'text')
+ call setline(1, range(100))
call assert_fails('|.44444444444444444444444', 'E1247:')
call assert_fails('|.9223372036854775806', 'E1247:')
+
+ $
+ yank 77777777777777777777
+ call assert_equal("99\n", @")
+
bwipe!
endfunc