Tomas Janousek 4fb099
#190350: vi mode glitch
Tomas Janousek 4fb099
Tomas Janousek 4fb099
Whenever you do some non-inserting edit command, like 'x' or 'd',
Tomas Janousek 4fb099
that becomes the command-to-repeat and no further insertions may be repeated.
Tomas Janousek 4fb099
Tomas Janousek 4fb099
1. Start a new bash shell
Tomas Janousek 4fb099
2. 'set -o vi'
Tomas Janousek 4fb099
2. Type 'kekepop<esc>hxi\<esc>.'
Tomas Janousek 4fb099
3. You end up with 'kekepp' instead of 'kekep\\p'.
Tomas Janousek 4fb099
Tomas Janousek 4fb099
This patch fixes it and tries to fix redoing the 'I' command as well.
Tomas Janousek 4fb099
I'm not sure about 'c', though.
Tomas Janousek 4fb099
Tomas Janousek ac6601
Signed-off-by: Tomas Janousek <tjanouse@redhat.com>
Tomas Janousek 4fb099
---
Tomas Janousek 4fb099
 lib/readline/misc.c      |    2 +-
Tomas Janousek 4fb099
 lib/readline/readline.c  |    2 +-
Tomas Janousek 4fb099
 lib/readline/readline.h  |    1 +
Tomas Janousek 4fb099
 lib/readline/vi_keymap.c |    2 +-
Tomas Janousek 4fb099
 lib/readline/vi_mode.c   |   21 +++++++++++++++++++--
Tomas Janousek 4fb099
 5 files changed, 23 insertions(+), 5 deletions(-)
Tomas Janousek 4fb099
Tomas Janousek 4fb099
diff --git a/lib/readline/misc.c b/lib/readline/misc.c
Tomas Janousek 4fb099
index e9c72c5..35d6348 100644
Tomas Janousek 4fb099
--- a/lib/readline/misc.c
Tomas Janousek 4fb099
+++ b/lib/readline/misc.c
Tomas Janousek 4fb099
@@ -560,7 +560,7 @@ rl_vi_editing_mode (count, key)
Tomas Janousek 4fb099
 #if defined (VI_MODE)
Tomas Janousek 4fb099
   _rl_set_insert_mode (RL_IM_INSERT, 1);	/* vi mode ignores insert mode */
Tomas Janousek 4fb099
   rl_editing_mode = vi_mode;
Tomas Janousek 4fb099
-  rl_vi_insertion_mode (1, key);
Tomas Janousek 4fb099
+  rl_vi_insert_mode (1, key);
Tomas Janousek 4fb099
 #endif /* VI_MODE */
Tomas Janousek 4fb099
 
Tomas Janousek 4fb099
   return 0;
Tomas Janousek 4fb099
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
Tomas Janousek 4fb099
index bd4d263..4b3d91b 100644
Tomas Janousek 4fb099
--- a/lib/readline/readline.c
Tomas Janousek 4fb099
+++ b/lib/readline/readline.c
Tomas Janousek 4fb099
@@ -370,7 +370,7 @@ readline_internal_setup ()
Tomas Janousek 4fb099
 
Tomas Janousek 4fb099
 #if defined (VI_MODE)
Tomas Janousek 4fb099
   if (rl_editing_mode == vi_mode)
Tomas Janousek 4fb099
-    rl_vi_insertion_mode (1, 'i');
Tomas Janousek 4fb099
+    rl_vi_insert_mode (1, 'i');
Tomas Janousek 4fb099
 #endif /* VI_MODE */
Tomas Janousek 4fb099
 
Tomas Janousek 4fb099
   if (rl_pre_input_hook)
Tomas Janousek 4fb099
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
Tomas Janousek 4fb099
index b71bf98..8527ebf 100644
Tomas Janousek 4fb099
--- a/lib/readline/readline.h
Tomas Janousek 4fb099
+++ b/lib/readline/readline.h
Tomas Janousek 4fb099
@@ -230,6 +230,7 @@ extern int rl_vi_next_word PARAMS((int, int));
Tomas Janousek 4fb099
 extern int rl_vi_end_word PARAMS((int, int));
Tomas Janousek 4fb099
 extern int rl_vi_insert_beg PARAMS((int, int));
Tomas Janousek 4fb099
 extern int rl_vi_append_mode PARAMS((int, int));
Tomas Janousek 4fb099
+extern int rl_vi_insert_mode PARAMS((int, int));
Tomas Janousek 4fb099
 extern int rl_vi_append_eol PARAMS((int, int));
Tomas Janousek 4fb099
 extern int rl_vi_eof_maybe PARAMS((int, int));
Tomas Janousek 4fb099
 extern int rl_vi_insertion_mode PARAMS((int, int));
Tomas Janousek 4fb099
diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c
Tomas Janousek 4fb099
index 4b48c75..3a017cc 100644
Tomas Janousek 4fb099
--- a/lib/readline/vi_keymap.c
Tomas Janousek 4fb099
+++ b/lib/readline/vi_keymap.c
Tomas Janousek 4fb099
@@ -151,7 +151,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
Tomas Janousek 4fb099
   { ISFUNC, rl_vi_char_search },		/* f */
Tomas Janousek 4fb099
   { ISFUNC, (rl_command_func_t *)0x0 },		/* g */
Tomas Janousek 4fb099
   { ISFUNC, rl_backward_char },			/* h */
Tomas Janousek 4fb099
-  { ISFUNC, rl_vi_insertion_mode },		/* i */
Tomas Janousek 4fb099
+  { ISFUNC, rl_vi_insert_mode },		/* i */
Tomas Janousek 4fb099
   { ISFUNC, rl_get_next_history },		/* j */
Tomas Janousek 4fb099
   { ISFUNC, rl_get_previous_history },		/* k */
Tomas Janousek 4fb099
   { ISFUNC, rl_forward_char },			/* l */
Tomas Janousek 4fb099
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
Tomas Janousek 4fb099
index b0da0ab..e859062 100644
Tomas Janousek 4fb099
--- a/lib/readline/vi_mode.c
Tomas Janousek 4fb099
+++ b/lib/readline/vi_mode.c
Tomas Janousek 4fb099
@@ -220,6 +220,15 @@ rl_vi_redo (count, c)
Tomas Janousek 4fb099
       if (rl_point > 0)
Tomas Janousek 4fb099
 	_rl_vi_backup ();
Tomas Janousek 4fb099
     }
Tomas Janousek 4fb099
+  /* Ditto for redoing an insert with `I', but move to the beginning of line
Tomas Janousek 4fb099
+     like the `I' command does. */
Tomas Janousek 4fb099
+  else if (_rl_vi_last_command == 'I' && vi_insert_buffer && *vi_insert_buffer)
Tomas Janousek 4fb099
+    {
Tomas Janousek 4fb099
+      rl_beg_of_line (1, 'I');
Tomas Janousek 4fb099
+      _rl_vi_stuff_insert (count);
Tomas Janousek 4fb099
+      if (rl_point > 0)
Tomas Janousek 4fb099
+	_rl_vi_backup ();
Tomas Janousek 4fb099
+    }
Tomas Janousek 4fb099
   else
Tomas Janousek 4fb099
     r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
Tomas Janousek 4fb099
   vi_redoing = 0;
Tomas Janousek 4fb099
@@ -584,7 +593,7 @@ rl_vi_insert_beg (count, key)
Tomas Janousek 4fb099
      int count, key;
Tomas Janousek 4fb099
 {
Tomas Janousek 4fb099
   rl_beg_of_line (1, key);
Tomas Janousek 4fb099
-  rl_vi_insertion_mode (1, key);
Tomas Janousek 4fb099
+  rl_vi_insert_mode (1, key);
Tomas Janousek 4fb099
   return (0);
Tomas Janousek 4fb099
 }
Tomas Janousek 4fb099
 
Tomas Janousek 4fb099
@@ -618,6 +627,14 @@ rl_vi_append_mode (count, key)
Tomas Janousek 4fb099
 }
Tomas Janousek 4fb099
 
Tomas Janousek 4fb099
 int
Tomas Janousek 4fb099
+rl_vi_insert_mode (count, key)
Tomas Janousek 4fb099
+     int count, key;
Tomas Janousek 4fb099
+{
Tomas Janousek 4fb099
+  rl_vi_start_inserting (key, 1, rl_arg_sign);
Tomas Janousek 4fb099
+  return (0);
Tomas Janousek 4fb099
+}
Tomas Janousek 4fb099
+
Tomas Janousek 4fb099
+int
Tomas Janousek 4fb099
 rl_vi_append_eol (count, key)
Tomas Janousek 4fb099
      int count, key;
Tomas Janousek 4fb099
 {
Tomas Janousek 4fb099
@@ -690,7 +707,7 @@ _rl_vi_done_inserting ()
Tomas Janousek 4fb099
     }
Tomas Janousek 4fb099
   else
Tomas Janousek 4fb099
     {
Tomas Janousek 4fb099
-      if ((_rl_vi_last_key_before_insert == 'i' || _rl_vi_last_key_before_insert == 'a') && rl_undo_list)
Tomas Janousek 4fb099
+      if ((_rl_vi_last_key_before_insert == 'i' || _rl_vi_last_key_before_insert == 'a' || _rl_vi_last_key_before_insert == 'I') && rl_undo_list)
Tomas Janousek 4fb099
         _rl_vi_save_insert (rl_undo_list);
Tomas Janousek 4fb099
       /* XXX - Other keys probably need to be checked. */
Tomas Janousek 4fb099
       else if (_rl_vi_last_key_before_insert == 'C')
Tomas Janousek 4fb099
-- 
Tomas Janousek 4fb099
1.5.3.7
Tomas Janousek 4fb099
Tomas Janousek 4fb099
Tomas Janousek 4fb099
-- 
Tomas Janousek 4fb099
Tomas Janousek, SW Engineer, Red Hat, Inc.
Tomas Janousek 4fb099