From 797f5fc5edfb47ba18e2d8cccf4041f1882dc265 Mon Sep 17 00:00:00 2001 From: gwenn <gtreguier@gmail.com> Date: Sat, 8 Apr 2017 18:13:18 +0200 Subject: [PATCH] Fix history-search-backward --- src/keymap.rs | 3 +++ src/lib.rs | 15 +++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/keymap.rs b/src/keymap.rs index e158bb51..71410660 100644 --- a/src/keymap.rs +++ b/src/keymap.rs @@ -255,6 +255,7 @@ impl EditState { } let (n, positive) = self.emacs_num_args(); // consume them in all cases if let Some(cmd) = self.custom_bindings.borrow().get(&key) { + debug!(target: "rustyline", "Custom command: {:?}", cmd); return Ok(if cmd.is_repeatable() { cmd.redo(Some(n)) } else { @@ -371,6 +372,7 @@ impl EditState { let no_num_args = self.num_args == 0; let n = self.vi_num_args(); // consume them in all cases if let Some(cmd) = self.custom_bindings.borrow().get(&key) { + debug!(target: "rustyline", "Custom command: {:?}", cmd); return Ok(if cmd.is_repeatable() { if no_num_args { cmd.redo(None) @@ -526,6 +528,7 @@ impl EditState { fn vi_insert<R: RawReader>(&mut self, rdr: &mut R) -> Result<Cmd> { let key = try!(rdr.next_key()); if let Some(cmd) = self.custom_bindings.borrow().get(&key) { + debug!(target: "rustyline", "Custom command: {:?}", cmd); return Ok(if cmd.is_repeatable() { cmd.redo(None) } else { diff --git a/src/lib.rs b/src/lib.rs index 19c0baba..db9176da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -564,17 +564,12 @@ fn edit_history_next(s: &mut State, history: &History, prev: bool) -> Result<()> fn edit_history_search(s: &mut State, history: &History, dir: Direction) -> Result<()> { if history.is_empty() { - return Ok(()); + return beep(); } - if s.history_index == history.len() { - if dir == Direction::Reverse { - // Save the current edited line before to overwrite it - s.snapshot(); - } else { - return Ok(()); - } + if s.history_index == history.len() && dir == Direction::Forward { + return beep(); } else if s.history_index == 0 && dir == Direction::Reverse { - return Ok(()); + return beep(); } if dir == Direction::Reverse { s.history_index -= 1; @@ -588,7 +583,7 @@ fn edit_history_search(s: &mut State, history: &History, dir: Direction) -> Resu s.line.update(buf, buf.len()); s.refresh_line() } else { - Ok(()) + beep() } } -- GitLab