bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

vi mode is unable to repeat insert actions after deletion etc.


From: Tomas Janousek
Subject: vi mode is unable to repeat insert actions after deletion etc.
Date: Tue, 15 Jan 2008 15:16:12 +0100
User-agent: Mutt/1.5.16 (2007-06-09)

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib  -D_GNU_SOURCE 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic 
-fasynchronous-unwind-tables
uname output: Linux tjanouse.englab.brq.redhat.com 2.6.18-53.el5 #1 SMP Wed Oct 
10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux
Machine Type: i686-redhat-linux-gnu

Bash Version: 3.2
Patch Level: 33
Release Status: release

Description:
        Whenever you do some non-inserting edit command, like 'x' or 'd', that
        becomes the command-to-repeat and no further insertions may be
        repeated.

Repeat-By:
        1. Start a new bash shell
        2. 'set -o vi'
        2. Type 'kekepop<esc>hxi\<esc>.'
        3. You end up with 'kekepp' instead of 'kekep\\p'.

Fix:

This patch fixes it and tries to fix redoing the 'I' command as well.
I'm not sure about 'c', though.

diff --git a/lib/readline/misc.c b/lib/readline/misc.c
index e9c72c5..35d6348 100644
--- a/lib/readline/misc.c
+++ b/lib/readline/misc.c
@@ -560,7 +560,7 @@ rl_vi_editing_mode (count, key)
 #if defined (VI_MODE)
   _rl_set_insert_mode (RL_IM_INSERT, 1);       /* vi mode ignores insert mode 
*/
   rl_editing_mode = vi_mode;
-  rl_vi_insertion_mode (1, key);
+  rl_vi_insert_mode (1, key);
 #endif /* VI_MODE */
 
   return 0;
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index bd4d263..4b3d91b 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -370,7 +370,7 @@ readline_internal_setup ()
 
 #if defined (VI_MODE)
   if (rl_editing_mode == vi_mode)
-    rl_vi_insertion_mode (1, 'i');
+    rl_vi_insert_mode (1, 'i');
 #endif /* VI_MODE */
 
   if (rl_pre_input_hook)
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index b71bf98..8527ebf 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -230,6 +230,7 @@ extern int rl_vi_next_word PARAMS((int, int));
 extern int rl_vi_end_word PARAMS((int, int));
 extern int rl_vi_insert_beg PARAMS((int, int));
 extern int rl_vi_append_mode PARAMS((int, int));
+extern int rl_vi_insert_mode PARAMS((int, int));
 extern int rl_vi_append_eol PARAMS((int, int));
 extern int rl_vi_eof_maybe PARAMS((int, int));
 extern int rl_vi_insertion_mode PARAMS((int, int));
diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c
index 4b48c75..3a017cc 100644
--- a/lib/readline/vi_keymap.c
+++ b/lib/readline/vi_keymap.c
@@ -151,7 +151,7 @@ KEYMAP_ENTRY_ARRAY vi_movement_keymap = {
   { ISFUNC, rl_vi_char_search },               /* f */
   { ISFUNC, (rl_command_func_t *)0x0 },                /* g */
   { ISFUNC, rl_backward_char },                        /* h */
-  { ISFUNC, rl_vi_insertion_mode },            /* i */
+  { ISFUNC, rl_vi_insert_mode },               /* i */
   { ISFUNC, rl_get_next_history },             /* j */
   { ISFUNC, rl_get_previous_history },         /* k */
   { ISFUNC, rl_forward_char },                 /* l */
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index b0da0ab..e859062 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -220,6 +220,15 @@ rl_vi_redo (count, c)
       if (rl_point > 0)
        _rl_vi_backup ();
     }
+  /* Ditto for redoing an insert with `I', but move to the beginning of line
+     like the `I' command does. */
+  else if (_rl_vi_last_command == 'I' && vi_insert_buffer && *vi_insert_buffer)
+    {
+      rl_beg_of_line (1, 'I');
+      _rl_vi_stuff_insert (count);
+      if (rl_point > 0)
+       _rl_vi_backup ();
+    }
   else
     r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
   vi_redoing = 0;
@@ -584,7 +593,7 @@ rl_vi_insert_beg (count, key)
      int count, key;
 {
   rl_beg_of_line (1, key);
-  rl_vi_insertion_mode (1, key);
+  rl_vi_insert_mode (1, key);
   return (0);
 }
 
@@ -618,6 +627,14 @@ rl_vi_append_mode (count, key)
 }
 
 int
+rl_vi_insert_mode (count, key)
+     int count, key;
+{
+  rl_vi_start_inserting (key, 1, rl_arg_sign);
+  return (0);
+}
+
+int
 rl_vi_append_eol (count, key)
      int count, key;
 {
@@ -690,7 +707,7 @@ _rl_vi_done_inserting ()
     }
   else
     {
-      if ((_rl_vi_last_key_before_insert == 'i' || 
_rl_vi_last_key_before_insert == 'a') && rl_undo_list)
+      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)
         _rl_vi_save_insert (rl_undo_list);
       /* XXX - Other keys probably need to be checked. */
       else if (_rl_vi_last_key_before_insert == 'C')

-- 
Tomas Janousek, SW Engineer, Red Hat, Inc.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]