]> granicus.if.org Git - vim/commitdiff
patch 9.0.0356: :echowindow sets the in_echowindow flag too early v9.0.0356
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Fri, 2 Sep 2022 11:16:21 +0000 (12:16 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 2 Sep 2022 11:16:21 +0000 (12:16 +0100)
Problem:    :echowindow sets the in_echowindow flag too early.
Solution:   Set in_echowindow only when outputting the text. (Yasuhiro
            Matsumoto, closes #11033)

src/eval.c
src/testdir/dumps/Test_echowin_eval.dump [new file with mode: 0644]
src/testdir/test_messages.vim
src/version.c

index f55d9de8ecf3b50c588742181a69ff24fd7cdcdf..2dfe8174ab0adeb25e20fe3c3e3a4462ce385792 100644 (file)
@@ -6728,10 +6728,6 @@ ex_execute(exarg_T *eap)
     long       start_lnum = SOURCING_LNUM;
 
     ga_init2(&ga, 1, 80);
-#ifdef HAS_MESSAGE_WINDOW
-    if (eap->cmdidx == CMD_echowindow)
-       start_echowindow();
-#endif
 
     if (eap->skip)
        ++emsg_skip;
@@ -6796,11 +6792,21 @@ ex_execute(exarg_T *eap)
            msg_sb_eol();
        }
 
-       if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echowindow)
+       if (eap->cmdidx == CMD_echomsg)
        {
            msg_attr(ga.ga_data, echo_attr);
            out_flush();
        }
+       else if (eap->cmdidx == CMD_echowindow)
+       {
+#ifdef HAS_MESSAGE_WINDOW
+           start_echowindow();
+#endif
+           msg_attr(ga.ga_data, echo_attr);
+#ifdef HAS_MESSAGE_WINDOW
+           end_echowindow();
+#endif
+       }
        else if (eap->cmdidx == CMD_echoconsole)
        {
            ui_write(ga.ga_data, (int)STRLEN(ga.ga_data), TRUE);
@@ -6832,10 +6838,6 @@ ex_execute(exarg_T *eap)
 
     if (eap->skip)
        --emsg_skip;
-#ifdef HAS_MESSAGE_WINDOW
-    if (eap->cmdidx == CMD_echowindow)
-       end_echowindow();
-#endif
     set_nextcmd(eap, arg);
 }
 
diff --git a/src/testdir/dumps/Test_echowin_eval.dump b/src/testdir/dumps/Test_echowin_eval.dump
new file mode 100644 (file)
index 0000000..80d5fc7
--- /dev/null
@@ -0,0 +1,8 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|═+0#e000002&@74
+|t|e|s|t| @70
+|1+0#0000000&|2|3| @53|0|,|0|-|1| @8|A|l@1| 
index 10af69c67d826676d85ac5d80c2522feb1f6ea7e..07a4b229a7ec1310f7665d526bfce0d75bed39fd 100644 (file)
@@ -420,5 +420,25 @@ func Test_echowindow()
   call delete('XtestEchowindow')
 endfunc
 
+" messages window should not be used while evaluating the :echowin argument
+func Test_echowin_eval()
+  CheckScreendump
+
+  let lines =<< trim END
+      func ShowMessage()
+        echo 123
+        return 'test'
+      endfunc
+      echowindow ShowMessage()
+  END
+  call writefile(lines, 'XtestEchowindow')
+  let buf = RunVimInTerminal('-S XtestEchowindow', #{rows: 8})
+  call VerifyScreenDump(buf, 'Test_echowin_eval', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('XtestEchowindow')
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index 356ac7796a7e45c261529ca0aa7171bd8a3f1edd..f017ba1d1ef294267f2e24e2f03775d9aef6ed8f 100644 (file)
@@ -707,6 +707,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    356,
 /**/
     355,
 /**/