@@ -25,7 +25,7 @@ struct cmdline_info
2525 int cmdlen ; /* number of chars in command line */
2626 int cmdpos ; /* current cursor position */
2727 int cmdspos ; /* cursor column on screen */
28- int cmdfirstc ; /* ':', '/', '?', '=' or NUL */
28+ int cmdfirstc ; /* ':', '/', '?', '=', '>' or NUL */
2929 int cmdindent ; /* number of spaces before cmdline */
3030 char_u * cmdprompt ; /* message in front of cmdline */
3131 int cmdattr ; /* attributes for prompt */
@@ -111,6 +111,9 @@ static int expand_showtail __ARGS((expand_T *xp));
111111#ifdef FEAT_CMDL_COMPL
112112static int expand_shellcmd __ARGS ((char_u * filepat , int * num_file , char_u * * * file , int flagsarg ));
113113static int ExpandRTDir __ARGS ((char_u * pat , int * num_file , char_u * * * file , char * dirname [ ]));
114+ # ifdef FEAT_CMDHIST
115+ static char_u * get_history_arg __ARGS ((expand_T * xp , int idx ));
116+ # endif
114117# if defined(FEAT_USR_CMDS ) && defined(FEAT_EVAL )
115118static int ExpandUserDefined __ARGS ((expand_T * xp , regmatch_T * regmatch , int * num_file , char_u * * * file ));
116119static int ExpandUserList __ARGS ((expand_T * xp , int * num_file , char_u * * * file ));
@@ -4628,6 +4631,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
46284631 {
46294632 {EXPAND_COMMANDS , get_command_name , FALSE, TRUE},
46304633 {EXPAND_BEHAVE , get_behave_arg , TRUE, TRUE},
4634+ #ifdef FEAT_CMDHIST
4635+ {EXPAND_HISTORY , get_history_arg , TRUE, TRUE},
4636+ #endif
46314637#ifdef FEAT_USR_CMDS
46324638 {EXPAND_USER_COMMANDS , get_user_commands , FALSE, TRUE},
46334639 {EXPAND_USER_CMD_FLAGS , get_user_cmd_flags , FALSE, TRUE},
@@ -5245,6 +5251,34 @@ static char *(history_names[]) =
52455251 NULL
52465252};
52475253
5254+ #if defined(FEAT_CMDL_COMPL ) || defined(PROTO )
5255+ /*
5256+ * Function given to ExpandGeneric() to obtain the possible first
5257+ * arguments of the ":history command.
5258+ */
5259+ static char_u *
5260+ get_history_arg (xp , idx )
5261+ expand_T * xp UNUSED ;
5262+ int idx ;
5263+ {
5264+ static char_u compl [2 ] = { NUL , NUL };
5265+ char * short_names = ":=@>?/" ;
5266+ int short_names_count = STRLEN (short_names );
5267+ int history_name_count = sizeof (history_names ) / sizeof (char * ) - 1 ;
5268+
5269+ if (idx < short_names_count )
5270+ {
5271+ compl [0 ] = (char_u )short_names [idx ];
5272+ return compl ;
5273+ }
5274+ if (idx < short_names_count + history_name_count )
5275+ return (char_u * )history_names [idx - short_names_count ];
5276+ if (idx == short_names_count + history_name_count )
5277+ return (char_u * )"all" ;
5278+ return NULL ;
5279+ }
5280+ #endif
5281+
52485282/*
52495283 * init_history() - Initialize the command line history.
52505284 * Also used to re-allocate the history when the size changes.
0 commit comments