summaryrefslogtreecommitdiff
path: root/bashline.c
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2019-02-18 09:56:34 -0500
committerChet Ramey <chet.ramey@case.edu>2019-02-18 09:56:34 -0500
commitbe4078d25ff3af268a6ef7ab56c8121f9a8dfb36 (patch)
tree67cd6be7804a9836d1efec97843a5892650c3380 /bashline.c
parent439b8c2c5f2981425aad0f0c70a80319f4eb5215 (diff)
downloadbash-be4078d25ff3af268a6ef7ab56c8121f9a8dfb36.tar.gz
commit bash-20190215 snapshot
Diffstat (limited to 'bashline.c')
-rw-r--r--bashline.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/bashline.c b/bashline.c
index 489be690..34e2e34a 100644
--- a/bashline.c
+++ b/bashline.c
@@ -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++;