diff options
author | Chet Ramey <chet.ramey@case.edu> | 2019-02-18 09:56:34 -0500 |
---|---|---|
committer | Chet Ramey <chet.ramey@case.edu> | 2019-02-18 09:56:34 -0500 |
commit | be4078d25ff3af268a6ef7ab56c8121f9a8dfb36 (patch) | |
tree | 67cd6be7804a9836d1efec97843a5892650c3380 /bashline.c | |
parent | 439b8c2c5f2981425aad0f0c70a80319f4eb5215 (diff) | |
download | bash-be4078d25ff3af268a6ef7ab56c8121f9a8dfb36.tar.gz |
commit bash-20190215 snapshot
Diffstat (limited to 'bashline.c')
-rw-r--r-- | bashline.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -310,16 +310,29 @@ static int completion_quoting_style = COMPLETE_BSQUOTE; /* Flag values for the final argument to bash_default_completion */ #define DEFCOMP_CMDPOS 1 +static rl_command_func_t *vi_tab_binding = rl_complete; + /* Change the readline VI-mode keymaps into or out of Posix.2 compliance. Called when the shell is put into or out of `posix' mode. */ void posix_readline_initialize (on_or_off) int on_or_off; { + static char kseq[2] = { CTRL ('I'), 0 }; /* TAB */ + if (on_or_off) rl_variable_bind ("comment-begin", "#"); #if defined (VI_MODE) - rl_bind_key_in_map (CTRL ('I'), on_or_off ? rl_insert : rl_complete, vi_insertion_keymap); + if (on_or_off) + { + vi_tab_binding = rl_function_of_keyseq (kseq, vi_insertion_keymap, (int *)NULL); + rl_bind_key_in_map (CTRL ('I'), rl_insert, vi_insertion_keymap); + } + else + { + if (rl_function_of_keyseq (kseq, vi_insertion_keymap, (int *)NULL) == rl_insert) + rl_bind_key_in_map (CTRL ('I'), vi_tab_binding, vi_insertion_keymap); + } #endif } @@ -964,11 +977,8 @@ edit_and_execute_command (count, c, editing_mode, edit_command) /* This breaks down when using command-oriented history and are not finished with the command, so we should not ignore the last command */ using_history (); - if (rl_line_buffer[0]) - { - current_command_line_count++; /* for rl_newline above */ - bash_add_history (rl_line_buffer); - } + current_command_line_count++; /* for rl_newline above */ + bash_add_history (rl_line_buffer); current_command_line_count = 0; /* for dummy history entry */ bash_add_history (""); history_lines_this_session++; |