diff --git a/examples/example.rs b/examples/example.rs index 9f047c64d9e7fd86851017cda8519e96977383c7..25c6ad3ace9801cc5e5f9c5e5f99577d8f73d693 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -70,7 +70,7 @@ impl log::Log for Logger { fn init_logger() -> Result<(), SetLoggerError> { log::set_logger(|max_log_level| { - max_log_level.set(LogLevelFilter::Info); - Box::new(Logger) - }) + max_log_level.set(LogLevelFilter::Info); + Box::new(Logger) + }) } diff --git a/src/history.rs b/src/history.rs index 054d181ead2b8850467c70b130406b5ee3826669..a9ebab97c42bc8601288bcd9da28b3f5992b49fa 100644 --- a/src/history.rs +++ b/src/history.rs @@ -58,9 +58,9 @@ impl History { if line.as_ref().is_empty() || (self.ignore_space && line.as_ref() - .chars() - .next() - .map_or(true, |c| c.is_whitespace())) { + .chars() + .next() + .map_or(true, |c| c.is_whitespace())) { return false; } if self.ignore_dups { diff --git a/src/keymap.rs b/src/keymap.rs index 696532acdff47a1d101b74f9de0573ad6b7a1fa6..87bb37b5e428297d47376a617597af260e70b6f2 100644 --- a/src/keymap.rs +++ b/src/keymap.rs @@ -48,13 +48,13 @@ pub enum Cmd { impl Cmd { fn is_repeatable_change(&self) -> bool { match *self { - Cmd::Insert(_, _) => true, - Cmd::Kill(_) => true, - Cmd::Replace(_, _) => true, - Cmd::SelfInsert(_, _) => true, - Cmd::TransposeChars => false, // TODO Validate - Cmd::ViYankTo(_) => true, + Cmd::Insert(_, _) | + Cmd::Kill(_) | + Cmd::Replace(_, _) | + Cmd::SelfInsert(_, _) | + Cmd::ViYankTo(_) | Cmd::Yank(_, _) => true, + Cmd::TransposeChars => false, // TODO Validate _ => false, } } diff --git a/src/lib.rs b/src/lib.rs index 264ea108b1a76323f33e317bb34d25e4dafd3b8c..420d2b6ebff4991a39765b6c8e2b2a7db31831fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -216,9 +216,9 @@ impl<'out, 'prompt> State<'out, 'prompt> { info.dwCursorPosition.Y -= self.cursor.row as i16; try!(self.term.set_console_cursor_position(info.dwCursorPosition)); let mut _count = 0; - try!(self.term.fill_console_output_character((info.dwSize.X * (self.old_rows as i16 + 1)) as - u32, - info.dwCursorPosition)); + try!(self.term + .fill_console_output_character((info.dwSize.X * (self.old_rows as i16 + 1)) as u32, + info.dwCursorPosition)); let mut ab = String::new(); // display the prompt ab.push_str(prompt); // TODO handle ansi escape code (SetConsoleTextAttribute) diff --git a/src/line_buffer.rs b/src/line_buffer.rs index 21dd06c437cac2122c7e7eaec6fb76602ff9a15b..ce05691f559cb444880006188a2a3854e9f7c3ca 100644 --- a/src/line_buffer.rs +++ b/src/line_buffer.rs @@ -22,7 +22,7 @@ pub enum WordAction { #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Direction { Forward, - Backward + Backward, } impl Default for Direction { @@ -179,7 +179,7 @@ impl LineBuffer { let push = self.pos == self.buf.len(); if n == 1 { self.buf.insert(self.pos, ch); - for (_, cl) in &self.cl { + for cl in self.cl.values() { cl.borrow_mut().insert_char(self.pos, ch); } } else { @@ -489,18 +489,18 @@ impl LineBuffer { }; if let Some(pos) = search_result { Some(match *cs { - CharSearch::Backward(_) => pos, - CharSearch::BackwardAfter(c) => pos + c.len_utf8(), - CharSearch::Forward(_) => shift + pos, - CharSearch::ForwardBefore(_) => { - shift + pos - - self.buf[..shift + pos] - .chars() - .next_back() - .unwrap() - .len_utf8() - } - }) + CharSearch::Backward(_) => pos, + CharSearch::BackwardAfter(c) => pos + c.len_utf8(), + CharSearch::Forward(_) => shift + pos, + CharSearch::ForwardBefore(_) => { + shift + pos - + self.buf[..shift + pos] + .chars() + .next_back() + .unwrap() + .len_utf8() + } + }) } else { None } @@ -628,7 +628,7 @@ impl LineBuffer { } pub fn insert_str(&mut self, idx: usize, s: &str) -> bool { - for (_, cl) in &self.cl { + for cl in self.cl.values() { cl.borrow_mut().insert_str(idx, s); } if idx == self.buf.len() { @@ -646,7 +646,7 @@ impl LineBuffer { } fn drain(&mut self, range: Range<usize>, dir: Direction) -> Drain { - for (_, cl) in &self.cl { + for cl in self.cl.values() { cl.borrow_mut().delete(range.start, &self.buf[range.start..range.end], dir); } self.buf.drain(range) @@ -704,13 +704,11 @@ impl LineBuffer { }; if let Some(pos) = search_result { Some(match cs { - CharSearch::Backward(_) | - CharSearch::BackwardAfter(_) => self.buf[pos..self.pos].to_owned(), - CharSearch::ForwardBefore(_) => self.buf[self.pos..pos].to_owned(), - CharSearch::Forward(c) => { - self.buf[self.pos..pos + c.len_utf8()].to_owned() - } - }) + CharSearch::Backward(_) | + CharSearch::BackwardAfter(_) => self.buf[pos..self.pos].to_owned(), + CharSearch::ForwardBefore(_) => self.buf[self.pos..pos].to_owned(), + CharSearch::Forward(c) => self.buf[self.pos..pos + c.len_utf8()].to_owned(), + }) } else { None } diff --git a/src/tty/unix.rs b/src/tty/unix.rs index 83b9479938bc02e18d4907c481a0df0be6f62841..7b77b6833cd11450d6c2560f7b7130cc8b9c7ac9 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -100,9 +100,9 @@ impl PosixRawReader { fn new(config: &Config) -> Result<PosixRawReader> { let stdin = StdinRaw {}; Ok(PosixRawReader { - chars: stdin.chars(), - timeout_ms: config.keyseq_timeout(), - }) + chars: stdin.chars(), + timeout_ms: config.keyseq_timeout(), + }) } fn escape_sequence(&mut self) -> Result<KeyPress> { diff --git a/src/tty/windows.rs b/src/tty/windows.rs index b03bddf630823c218cfa8385da735323f4c9a592..6ad88444310b3df978ccfac4d4d38f30602a9f18 100644 --- a/src/tty/windows.rs +++ b/src/tty/windows.rs @@ -79,9 +79,9 @@ impl ConsoleRawReader { pub fn new() -> Result<ConsoleRawReader> { let handle = try!(get_std_handle(STDIN_FILENO)); Ok(ConsoleRawReader { - handle: handle, - buf: None, - }) + handle: handle, + buf: None, + }) } } @@ -288,9 +288,9 @@ impl Term for Console { let raw = raw | winapi::wincon::ENABLE_WINDOW_INPUT; check!(kernel32::SetConsoleMode(self.stdin_handle, raw)); Ok(Mode { - original_mode: original_mode, - stdin_handle: self.stdin_handle, - }) + original_mode: original_mode, + stdin_handle: self.stdin_handle, + }) } fn create_reader(&self, _: &Config) -> Result<ConsoleRawReader> { diff --git a/src/undo.rs b/src/undo.rs index 710b4c09f4ded933a5543be5623f348e3a6f37da..0736f909b290d3139a68dfc90d9357b6d5a436cf 100644 --- a/src/undo.rs +++ b/src/undo.rs @@ -117,9 +117,9 @@ impl Changeset { pub fn insert_str<S: Into<String>>(&mut self, idx: usize, string: S) { self.redos.clear(); self.undos.push(Change { - idx: idx, - action: Action::Insert(string.into()), - }); + idx: idx, + action: Action::Insert(string.into()), + }); } pub fn delete<S: AsRef<str> + Into<String>>(&mut self, idx: usize, string: S) { @@ -127,9 +127,9 @@ impl Changeset { if !Self::single_char(string.as_ref()) { self.undos.push(Change { - idx: idx, - action: Action::Delete(string.into()), - }); + idx: idx, + action: Action::Delete(string.into()), + }); return; } let last_change = self.undos.pop(); @@ -152,16 +152,16 @@ impl Changeset { } else { self.undos.push(last_change); self.undos.push(Change { - idx: idx, - action: Action::Delete(string.into()), - }); + idx: idx, + action: Action::Delete(string.into()), + }); } } None => { self.undos.push(Change { - idx: idx, - action: Action::Delete(string.into()), - }); + idx: idx, + action: Action::Delete(string.into()), + }); } }; }