]> granicus.if.org Git - vim/commitdiff
patch 7.4.1662 v7.4.1662
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Mar 2016 21:56:46 +0000 (22:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Mar 2016 21:56:46 +0000 (22:56 +0100)
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.

src/channel.c
src/testdir/test_channel.py
src/testdir/test_channel.vim
src/version.c

index 64393f974c920ff57746219c20137371190a4f44..22f63b3a83580365b21c582e086970116bcb8052 100644 (file)
@@ -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)
     {
index 227780a5eb6325854526cfb316b6574285d8704f..b5a912c078c603ddc57e6256d5b9b538529b136d 100644 (file)
@@ -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"]'
index b356c88fe48fbfb68d97389a1924fcb30d3a9b3e..705122317ab6c65ed07187444730ae02470baf91 100644 (file)
@@ -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('$'))
index 7e63f1fa6be0f0fa7a00d3b676cd69c2167ff7b8..b19190daa36f451c018aa8a15c238b86e162bc8c 100644 (file)
@@ -748,6 +748,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1662,
 /**/
     1661,
 /**/