Patch 9.0.0988
Problem:    Using feedkeys() does not show up in a channel log.
Solution:   Add ch_log() calls and clean up the code.
Files:      src/evalfunc.c


*** ../vim-9.0.0987/src/evalfunc.c      2022-11-30 18:11:52.690904297 +0000
--- src/evalfunc.c      2022-12-02 13:36:40.294568848 +0000
***************
*** 4343,4349 ****
      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,
--- 4343,4348 ----
***************
*** 4379,4451 ****
  
      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)
-           {
  #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
!           }
!           else
!           {
!               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;
!           }
            vim_free(keys_esc);
  
!           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;
  
!               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;
            }
        }
      }
  }
--- 4378,4456 ----
  
      if (*keys != NUL || execute)
      {
!       if (lowlevel)
        {
  #ifdef USE_INPUT_BUF
!           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
!           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;
! 
            vim_free(keys_esc);
+       }
  
!       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)
!           {
!               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;
        }
      }
  }
*** ../vim-9.0.0987/src/version.c       2022-12-02 13:20:16.464758265 +0000
--- src/version.c       2022-12-02 13:26:00.589664052 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     988,
  /**/

-- 
panic("Foooooooood fight!");
        -- In the kernel source aha1542.c, after detecting a bad segment list

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221202133803.194B91C06AE%40moolenaar.net.

Raspunde prin e-mail lui