diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-26 22:56:46 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-26 22:56:46 +0100 |
commit | c4dcd60c76666bf113719f929709ad6120eb6528 (patch) | |
tree | 5e6312286de30efa69d0f85443c67ced43b782a2 | |
parent | fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d (diff) | |
download | vim-git-c4dcd60c76666bf113719f929709ad6120eb6528.tar.gz |
patch 7.4.1662v7.4.1662
Problem: No test for an invalid Ex command on a channel.
Solution: Test handling an invalid command gracefully. Avoid getting an
error message, do write it to the channel log.
-rw-r--r-- | src/channel.c | 9 | ||||
-rw-r--r-- | src/testdir/test_channel.py | 5 | ||||
-rw-r--r-- | src/testdir/test_channel.vim | 5 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/src/channel.c b/src/channel.c index 64393f974..22f63b3a8 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1661,8 +1661,17 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv) if (STRCMP(cmd, "ex") == 0) { + int save_called_emsg = called_emsg; + + called_emsg = FALSE; ch_logs(channel, "Executing ex command '%s'", (char *)arg); + ++emsg_silent; do_cmdline_cmd(arg); + --emsg_silent; + if (called_emsg) + ch_logs(channel, "Ex command error: '%s'", + (char *)get_vim_var_str(VV_ERRMSG)); + called_emsg = save_called_emsg; } else if (STRCMP(cmd, "normal") == 0) { diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py index 227780a5e..b5a912c07 100644 --- a/src/testdir/test_channel.py +++ b/src/testdir/test_channel.py @@ -73,6 +73,11 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): print("sending: {0}".format(cmd)) self.request.sendall(cmd.encode('utf-8')) response = "ok" + elif decoded[1] == 'bad command': + cmd = '["ex","foo bar"]' + print("sending: {0}".format(cmd)) + self.request.sendall(cmd.encode('utf-8')) + response = "ok" elif decoded[1] == 'do normal': # Send a normal command. cmd = '["normal","G$s more\u001b"]' diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index b356c88fe..705122317 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -151,6 +151,11 @@ func s:communicate(port) call assert_equal('added1', getline(line('$') - 1)) call assert_equal('added2', getline('$')) + " Request command "foo bar", which fails silently. + call assert_equal('ok', ch_evalexpr(handle, 'bad command')) + call s:waitFor('v:errmsg =~ "E492"') + call assert_true(v:errmsg =~ 'E492:.*foo bar') + call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100})) call s:waitFor('"added more" == getline("$")') call assert_equal('added more', getline('$')) diff --git a/src/version.c b/src/version.c index 7e63f1fa6..b19190daa 100644 --- a/src/version.c +++ b/src/version.c @@ -749,6 +749,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1662, +/**/ 1661, /**/ 1660, |