@@ -42,6 +42,11 @@ static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0};
4242
4343static int typeahead_char = 0 ; // typeahead char that's not flushed
4444
45+ #ifdef FEAT_EVAL
46+ static char_u typedchars [MAXMAPLEN + 1 ] = { NUL }; // typed chars before map
47+ static int typedchars_pos = 0 ;
48+ #endif
49+
4550/*
4651 * When block_redo is TRUE the redo buffer will not be changed.
4752 * Used by edit() to repeat insertions.
@@ -1709,6 +1714,13 @@ updatescript(int c)
17091714 ml_sync_all (c == 0 , TRUE);
17101715 count = 0 ;
17111716 }
1717+ #ifdef FEAT_EVAL
1718+ if (typedchars_pos < MAXMAPLEN )
1719+ {
1720+ typedchars [typedchars_pos ] = c ;
1721+ typedchars_pos ++ ;
1722+ }
1723+ #endif
17121724}
17131725
17141726/*
@@ -2135,6 +2147,9 @@ vgetc(void)
21352147
21362148#ifdef FEAT_EVAL
21372149 c = do_key_input_pre (c );
2150+
2151+ // Clear the next typedchars_pos
2152+ typedchars_pos = 0 ;
21382153#endif
21392154
21402155 // Need to process the character before we know it's safe to do something
@@ -2175,6 +2190,9 @@ do_key_input_pre(int c)
21752190 else
21762191 buf [(* mb_char2bytes )(c , buf )] = NUL ;
21772192
2193+ typedchars [typedchars_pos ] = NUL ;
2194+ vim_unescape_csi (typedchars );
2195+
21782196 get_mode (curr_mode );
21792197
21802198 // Lock the text to avoid weird things from happening.
@@ -2183,6 +2201,7 @@ do_key_input_pre(int c)
21832201
21842202 v_event = get_v_event (& save_v_event );
21852203 (void )dict_add_bool (v_event , "typed" , KeyTyped );
2204+ (void )dict_add_string (v_event , "typedchar" , typedchars );
21862205
21872206 if (apply_autocmds (EVENT_KEYINPUTPRE , curr_mode , curr_mode , FALSE, curbuf )
21882207 && STRCMP (buf , get_vim_var_str (VV_CHAR )) != 0 )
0 commit comments