]> granicus.if.org Git - vim/commitdiff
patch 8.2.3082: a channel command "echoerr" does not show anything v8.2.3082
authorBram Moolenaar <Bram@vim.org>
Thu, 1 Jul 2021 20:11:28 +0000 (22:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 1 Jul 2021 20:11:28 +0000 (22:11 +0200)
Problem:    A channel command "echoerr" does not show anything.
Solution:   Do not use silent errors when using an "echoerr" command.
            (closes #8494)

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

index 5d89413503fc8f7d1a5375298544ada245dc4c4f..65757f1d7e8b4c8aec2053ae98224e273dc5099f 100644 (file)
@@ -2486,12 +2486,17 @@ channel_exe_cmd(channel_T *channel, ch_part_T part, typval_T *argv)
 
     if (STRCMP(cmd, "ex") == 0)
     {
-       int called_emsg_before = called_emsg;
+       int     called_emsg_before = called_emsg;
+       char_u  *p = arg;
+       int     do_emsg_silent;
 
        ch_log(channel, "Executing ex command '%s'", (char *)arg);
-       ++emsg_silent;
+       do_emsg_silent = !checkforcmd(&p, "echoerr", 5);
+       if (do_emsg_silent)
+           ++emsg_silent;
        do_cmdline_cmd(arg);
-       --emsg_silent;
+       if (do_emsg_silent)
+           --emsg_silent;
        if (called_emsg > called_emsg_before)
            ch_log(channel, "Ex command error: '%s'",
                                          (char *)get_vim_var_str(VV_ERRMSG));
index 8dba3ba4ca79ec414e2d0a46569859bd81bf4c7e..9684bb933a147923e2e71552618b201b7b1636ec 100644 (file)
@@ -109,6 +109,11 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
                         print("sending: {0}".format(cmd))
                         self.request.sendall(cmd.encode('utf-8'))
                         response = "ok"
+                    elif decoded[1] == 'echoerr':
+                        cmd = '["ex","echoerr \\\"this is an error\\\""]'
+                        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))
index e9cc258f04fc2012abe6c2927005c5ed86061e04..37dfd258619c79e76351aae1b731ba069a54587a 100644 (file)
@@ -115,6 +115,18 @@ func Ch_communicate(port)
   call WaitForAssert({-> assert_equal("added2", getline("$"))})
   call assert_equal('added1', getline(line('$') - 1))
 
+  " Request command "echoerr 'this is an error'".
+  " This will throw an exception, catch it here.
+  let caught = 'no'
+  try
+    call assert_equal('ok', ch_evalexpr(handle, 'echoerr'))
+  catch /this is an error/
+    let caught = 'yes'
+  endtry
+  if caught != 'yes'
+    call assert_report("Expected exception from error message")
+  endif
+
   " Request command "foo bar", which fails silently.
   call assert_equal('ok', ch_evalexpr(handle, 'bad command'))
   call WaitForAssert({-> assert_match("E492:.*foo bar", v:errmsg)})
index e3bdedefbdec1f25d19d7b54dcc0e3ff14abaaa0..532e747871b38c969da9ecf176fd7056be821586 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3082,
 /**/
     3081,
 /**/