diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_docmd.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 18490bd60c..d4fe55392e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2904,9 +2904,16 @@ int checkforcmd(char **pp, char *cmd, int len) /// invisible otherwise. static void append_command(char *cmd) { + size_t len = STRLEN(IObuff); char *s = cmd; char *d; + if (len > IOSIZE - 100) { + // Not enough space, truncate and put in "...". + d = (char *)IObuff + IOSIZE - 100; + d -= utf_head_off(IObuff, (const char_u *)d); + STRCPY(d, "..."); + } STRCAT(IObuff, ": "); d = (char *)IObuff + STRLEN(IObuff); while (*s != NUL && (char_u *)d - IObuff + 5 < IOSIZE) { diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 8ee894c35f..b00764e0dd 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -1361,4 +1361,9 @@ func Test_recursive_register() call assert_equal('yes', caught) endfunc +func Test_long_error_message() + " the error should be truncated, not overrun IObuff + silent! norm Q00000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +endfunc + " vim: shiftwidth=2 sts=2 expandtab |