diff src/eval.c @ 29966:5dfd4bd66ad8 v9.0.0321

patch 9.0.0321: cannot use the message popup window directly Commit: https://github.com/vim/vim/commit/37fef16c225eabed28a3c7a0542d2eeef30d812b Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 29 18:16:32 2022 +0100 patch 9.0.0321: cannot use the message popup window directly Problem: Cannot use the message popup window directly. Solution: Add ":echowindow".
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Aug 2022 19:30:04 +0200
parents 935717599faa
children bb0e525e1393
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -2078,7 +2078,8 @@ set_context_for_expression(
     if ((cmdidx == CMD_execute
 		|| cmdidx == CMD_echo
 		|| cmdidx == CMD_echon
-		|| cmdidx == CMD_echomsg)
+		|| cmdidx == CMD_echomsg
+		|| cmdidx == CMD_echowindow)
 	    && xp->xp_context == EXPAND_EXPRESSION)
     {
 	for (;;)
@@ -6709,6 +6710,7 @@ get_echo_attr(void)
 /*
  * ":execute expr1 ..."	execute the result of an expression.
  * ":echomsg expr1 ..."	Print a message
+ * ":echowindow expr1 ..." Print a message in the messages window
  * ":echoerr expr1 ..."	Print an error
  * ":echoconsole expr1 ..." Print a message on stdout
  * Each gets spaces around each argument and a newline at the end for
@@ -6726,6 +6728,9 @@ ex_execute(exarg_T *eap)
     long	start_lnum = SOURCING_LNUM;
 
     ga_init2(&ga, 1, 80);
+#ifdef HAS_MESSAGE_WINDOW
+    in_echowindow = (eap->cmdidx == CMD_echowindow);
+#endif
 
     if (eap->skip)
 	++emsg_skip;
@@ -6780,7 +6785,9 @@ ex_execute(exarg_T *eap)
 	// use the first line of continuation lines for messages
 	SOURCING_LNUM = start_lnum;
 
-	if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echoerr)
+	if (eap->cmdidx == CMD_echomsg
+		|| eap->cmdidx == CMD_echowindow
+		|| eap->cmdidx == CMD_echoerr)
 	{
 	    // Mark the already saved text as finishing the line, so that what
 	    // follows is displayed on a new line when scrolling back at the
@@ -6788,7 +6795,7 @@ ex_execute(exarg_T *eap)
 	    msg_sb_eol();
 	}
 
-	if (eap->cmdidx == CMD_echomsg)
+	if (eap->cmdidx == CMD_echomsg || eap->cmdidx == CMD_echowindow)
 	{
 	    msg_attr(ga.ga_data, echo_attr);
 	    out_flush();
@@ -6835,6 +6842,7 @@ ex_execute(exarg_T *eap)
 	if (msg_col == 0)
 	    msg_col = 1;
     }
+    in_echowindow = FALSE;
 #endif
     set_nextcmd(eap, arg);
 }