From 98b50b67da7a02aa9c8a35e2ae980eb6532ccbe4 Mon Sep 17 00:00:00 2001
From: gwenn <gtreguier@gmail.com>
Date: Sat, 4 Mar 2017 18:18:53 +0100
Subject: [PATCH] Fix vi redo

---
 src/keymap.rs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/keymap.rs b/src/keymap.rs
index c0299de0..990467b9 100644
--- a/src/keymap.rs
+++ b/src/keymap.rs
@@ -168,6 +168,7 @@ pub struct EditState {
     // numeric arguments: http://web.mit.edu/gnu/doc/html/rlman_1.html#SEC7
     num_args: i16,
     last_cmd: Cmd, // vi only
+    consecutive_insert: bool,
     last_char_search: Option<CharSearch>, // vi only
 }
 
@@ -178,6 +179,7 @@ impl EditState {
             insert: true,
             num_args: 0,
             last_cmd: Cmd::Noop,
+            consecutive_insert: false,
             last_char_search: None,
         }
     }
@@ -500,6 +502,10 @@ impl EditState {
         if cmd.is_repeatable_change() {
             self.update_last_cmd(cmd.clone());
         }
+        self.consecutive_insert = match cmd {
+            Cmd::SelfInsert(_, _) => true,
+            _ => false,
+        };
         Ok(cmd)
     }
 
@@ -686,7 +692,9 @@ impl EditState {
 
     fn update_last_cmd(&mut self, new: Cmd) {
         // consecutive char inserts are repeatable not only the last one...
-        if let Cmd::SelfInsert(_, c) = new {
+        if !self.consecutive_insert {
+            self.last_cmd = new;
+        } else if let Cmd::SelfInsert(_, c) = new {
             match self.last_cmd {
                 Cmd::SelfInsert(_, pc) => {
                     let mut text = String::new();
-- 
GitLab