changeset 31309:472ef2fdaa89 v9.0.0988

patch 9.0.0988: using feedkeys() does not show up in a channel log Commit: https://github.com/vim/vim/commit/b55ae8ce42c8a83d14bfde2c138fcc74f447de68 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 2 13:37:36 2022 +0000 patch 9.0.0988: using feedkeys() does not show up in a channel log Problem: Using feedkeys() does not show up in a channel log. Solution: Add ch_log() calls and clean up the code.
author Bram Moolenaar <Bram@vim.org>
date Fri, 02 Dec 2022 14:45:03 +0100
parents 3eeddaac4d11
children 64480d528b2f
files src/evalfunc.c src/version.c
diffstat 2 files changed, 69 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4343,7 +4343,6 @@ f_feedkeys(typval_T *argvars, typval_T *
     int		context = FALSE;
     int		dangerous = FALSE;
     int		lowlevel = FALSE;
-    char_u	*keys_esc;
 
     // This is not allowed in the sandbox.  If the commands would still be
     // executed in the sandbox it would be OK, but it probably happens later,
@@ -4379,73 +4378,79 @@ f_feedkeys(typval_T *argvars, typval_T *
 
     if (*keys != NUL || execute)
     {
-	// Need to escape K_SPECIAL and CSI before putting the string in the
-	// typeahead buffer.
-	keys_esc = vim_strsave_escape_csi(keys);
-	if (keys_esc != NULL)
-	{
-	    if (lowlevel)
-	    {
+	if (lowlevel)
+	{
 #ifdef USE_INPUT_BUF
-		int len = (int)STRLEN(keys);
-
-		for (int idx = 0; idx < len; ++idx)
-		{
-		    // if a CTRL-C was typed, set got_int, similar to what
-		    // happens in fill_input_buf()
-		    if (keys[idx] == 3 && ctrl_c_interrupts && typed)
-			got_int = TRUE;
-		    add_to_input_buf(keys + idx, 1);
-		}
-#else
-		emsg(_(e_lowlevel_input_not_supported));
-#endif
+	    ch_log(NULL, "feedkeys() lowlevel: %s", keys);
+
+	    int len = (int)STRLEN(keys);
+	    for (int idx = 0; idx < len; ++idx)
+	    {
+		// if a CTRL-C was typed, set got_int, similar to what
+		// happens in fill_input_buf()
+		if (keys[idx] == 3 && ctrl_c_interrupts && typed)
+		    got_int = TRUE;
+		add_to_input_buf(keys + idx, 1);
 	    }
-	    else
-	    {
-		ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
-				  insert ? 0 : typebuf.tb_len, !typed, FALSE);
-		if (vgetc_busy
+#else
+	    emsg(_(e_lowlevel_input_not_supported));
+#endif
+	}
+	else
+	{
+	    // Need to escape K_SPECIAL and CSI before putting the string in
+	    // the typeahead buffer.
+	    char_u *keys_esc = vim_strsave_escape_csi(keys);
+	    if (keys_esc == NULL)
+		return;
+
+	    ch_log(NULL, "feedkeys(%s): %s", typed ? "typed" : "", keys);
+
+	    ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
+				   insert ? 0 : typebuf.tb_len, !typed, FALSE);
+	    if (vgetc_busy
 #ifdef FEAT_TIMERS
-			|| timer_busy
-#endif
-			|| input_busy)
-		    typebuf_was_filled = TRUE;
-	    }
+		    || timer_busy
+#endif
+		    || input_busy)
+		typebuf_was_filled = TRUE;
+
 	    vim_free(keys_esc);
-
-	    if (execute)
+	}
+
+	if (execute)
+	{
+	    int		save_msg_scroll = msg_scroll;
+	    sctx_T	save_sctx;
+
+	    // Avoid a 1 second delay when the keys start Insert mode.
+	    msg_scroll = FALSE;
+
+	    ch_log(NULL, "feedkeys() executing");
+
+	    if (context)
 	    {
-		int	save_msg_scroll = msg_scroll;
-		sctx_T	save_sctx;
-
-		// Avoid a 1 second delay when the keys start Insert mode.
-		msg_scroll = FALSE;
-
-		if (context)
-		{
-		    save_sctx = current_sctx;
-		    current_sctx.sc_sid = 0;
-		    current_sctx.sc_version = 0;
-		}
-
-		if (!dangerous)
-		{
-		    ++ex_normal_busy;
-		    ++in_feedkeys;
-		}
-		exec_normal(TRUE, lowlevel, TRUE);
-		if (!dangerous)
-		{
-		    --ex_normal_busy;
-		    --in_feedkeys;
-		}
-
-		msg_scroll |= save_msg_scroll;
-
-		if (context)
-		    current_sctx = save_sctx;
+		save_sctx = current_sctx;
+		current_sctx.sc_sid = 0;
+		current_sctx.sc_version = 0;
+	    }
+
+	    if (!dangerous)
+	    {
+		++ex_normal_busy;
+		++in_feedkeys;
 	    }
+	    exec_normal(TRUE, lowlevel, TRUE);
+	    if (!dangerous)
+	    {
+		--ex_normal_busy;
+		--in_feedkeys;
+	    }
+
+	    msg_scroll |= save_msg_scroll;
+
+	    if (context)
+		current_sctx = save_sctx;
 	}
     }
 }
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    988,
+/**/
     987,
 /**/
     986,