diff --git a/src/edit.rs b/src/edit.rs index f9fcca874a1e30b248bac37c8b6631431af9acd5..4fc19a37e5d294da2ae3a58a2bc9d2c483b9db56 100644 --- a/src/edit.rs +++ b/src/edit.rs @@ -322,13 +322,12 @@ impl<'out, 'prompt> State<'out, 'prompt> { } pub fn edit_insert_text(&mut self, text: &str) -> Result<()> { - if !text.is_empty() { - let cursor = self.line.pos(); - self.line.insert_str(cursor, text); - self.refresh_line() - } else { - Ok(()) + if text.is_empty() { + return Ok(()); } + let cursor = self.line.pos(); + self.line.insert_str(cursor, text); + self.refresh_line() } pub fn edit_delete(&mut self, n: RepeatCount) -> Result<()> { diff --git a/src/keymap.rs b/src/keymap.rs index d36f8e2e9b919f3ae2009ce1ee251b1d2af0aaf9..b9c4a7ad4789dd16e6d1a40f316ab9278a5ac8fb 100644 --- a/src/keymap.rs +++ b/src/keymap.rs @@ -479,20 +479,17 @@ impl InputState { loop { try!(wrt.refresh_prompt_and_line(&format!("(arg: {}) ", self.num_args))); let key = try!(rdr.next_key(false)); - match key { - KeyPress::Char(digit @ '0'...'9') => { - if self.num_args.abs() < 1000 { - // shouldn't ever need more than 4 digits - self.num_args = self - .num_args - .saturating_mul(10) - .saturating_add(digit.to_digit(10).unwrap() as i16); - } - } - _ => { - try!(wrt.refresh_line()); - return Ok(key); + if let KeyPress::Char(digit @ '0'...'9') = key { + if self.num_args.abs() < 1000 { + // shouldn't ever need more than 4 digits + self.num_args = self + .num_args + .saturating_mul(10) + .saturating_add(digit.to_digit(10).unwrap() as i16); } + } else { + try!(wrt.refresh_line()); + return Ok(key); }; } } diff --git a/src/keys.rs b/src/keys.rs index 584101665369f29dc35f53975ddc5ec8a8d05906..273236a575f481b113c2b7a8208771d74a74738c 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -32,7 +32,7 @@ pub enum KeyPress { Up, } -#[allow(match_same_arms)] +#[allow(clippy::match_same_arms)] pub fn char_to_key_press(c: char) -> KeyPress { if !c.is_control() { return KeyPress::Char(c); diff --git a/src/kill_ring.rs b/src/kill_ring.rs index b5d87780a496c8d48e6b6f8a4763014917404896..03a202f2c8c8094c82fd9bb880b5794858b233af 100644 --- a/src/kill_ring.rs +++ b/src/kill_ring.rs @@ -41,34 +41,31 @@ impl KillRing { /// Add `text` to the kill-ring. pub fn kill(&mut self, text: &str, dir: Mode) { - match self.last_action { - Action::Kill => { - if self.slots.capacity() == 0 { - // disabled - return; - } - match dir { - Mode::Append => self.slots[self.index].push_str(text), - Mode::Prepend => self.slots[self.index].insert_str(0, text), - }; + if let Action::Kill = self.last_action { + if self.slots.capacity() == 0 { + // disabled + return; } - _ => { - self.last_action = Action::Kill; - if self.slots.capacity() == 0 { - // disabled - return; - } - if self.index == self.slots.capacity() - 1 { - // full - self.index = 0; - } else if !self.slots.is_empty() { - self.index += 1; - } - if self.index == self.slots.len() { - self.slots.push(String::from(text)) - } else { - self.slots[self.index] = String::from(text); - } + match dir { + Mode::Append => self.slots[self.index].push_str(text), + Mode::Prepend => self.slots[self.index].insert_str(0, text), + }; + } else { + self.last_action = Action::Kill; + if self.slots.capacity() == 0 { + // disabled + return; + } + if self.index == self.slots.capacity() - 1 { + // full + self.index = 0; + } else if !self.slots.is_empty() { + self.index += 1; + } + if self.index == self.slots.len() { + self.slots.push(String::from(text)) + } else { + self.slots[self.index] = String::from(text); } } } diff --git a/src/lib.rs b/src/lib.rs index f41641f03aa689f95bb6c01b4033d6c7a57b8b36..1452f94d665af1c183157de83c92d642be365911 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ //! } //! ``` #![allow(unknown_lints)] +// #![feature(tool_lints)] unstable feature extern crate dirs; extern crate libc; @@ -675,7 +676,7 @@ pub struct Editor<H: Helper> { custom_bindings: Arc<RwLock<HashMap<KeyPress, Cmd>>>, } -#[allow(new_without_default)] +#[allow(clippy::new_without_default)] impl<H: Helper> Editor<H> { /// Create an editor with the default configuration pub fn new() -> Editor<H> { diff --git a/src/line_buffer.rs b/src/line_buffer.rs index e17fd621f0a9080d04612147defca7baf02c8e80..ae3fe70c8bf9ad30aff2e6a99dd47801eb55cb20 100644 --- a/src/line_buffer.rs +++ b/src/line_buffer.rs @@ -364,25 +364,19 @@ impl LineBuffer { sow = 0; let mut gj = gis.next(); 'inner: loop { - match gj { - Some((j, y)) => { - let gi = gis.next(); - match gi { - Some((_, x)) => { - if is_start_of_word(word_def, x, y) { - sow = j; - break 'inner; - } - gj = gi; - } - None => { - break 'outer; - } + if let Some((j, y)) = gj { + let gi = gis.next(); + if let Some((_, x)) = gi { + if is_start_of_word(word_def, x, y) { + sow = j; + break 'inner; } - } - None => { + gj = gi; + } else { break 'outer; } + } else { + break 'outer; } } } @@ -428,32 +422,26 @@ impl LineBuffer { wp = 0; gi = gis.next(); 'inner: loop { - match gi { - Some((i, x)) => { - let gj = gis.next(); - match gj { - Some((j, y)) => { - if at == At::Start && is_start_of_word(word_def, x, y) { - wp = j; - break 'inner; - } else if at != At::Start && is_end_of_word(word_def, x, y) { - if word_def == Word::Emacs || at == At::AfterEnd { - wp = j; - } else { - wp = i; - } - break 'inner; - } - gi = gj; - } - None => { - break 'outer; + if let Some((i, x)) = gi { + let gj = gis.next(); + if let Some((j, y)) = gj { + if at == At::Start && is_start_of_word(word_def, x, y) { + wp = j; + break 'inner; + } else if at != At::Start && is_end_of_word(word_def, x, y) { + if word_def == Word::Emacs || at == At::AfterEnd { + wp = j; + } else { + wp = i; } + break 'inner; } - } - None => { + gi = gj; + } else { break 'outer; } + } else { + break 'outer; } } } diff --git a/src/tty/unix.rs b/src/tty/unix.rs index ffb81e9783b4bc95fce3e82facbf7c0b0e23b300..059c322b2cf6ec5e45e10d2f44817a3f8ac0a7aa 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -27,7 +27,7 @@ const STDOUT_FILENO: libc::c_int = libc::STDOUT_FILENO; /// Unsupported Terminals that don't support RAW mode static UNSUPPORTED_TERM: [&'static str; 3] = ["dumb", "cons25", "emacs"]; -#[allow(identity_conversion)] +#[allow(clippy::identity_conversion)] fn get_win_size() -> (usize, usize) { use std::mem::zeroed; @@ -559,7 +559,7 @@ impl Renderer for PosixRenderer { } static SIGWINCH_ONCE: sync::Once = sync::ONCE_INIT; -static SIGWINCH: atomic::AtomicBool = atomic::ATOMIC_BOOL_INIT; +static SIGWINCH: atomic::AtomicBool = atomic::AtomicBool::new(false); fn install_sigwinch_handler() { SIGWINCH_ONCE.call_once(|| unsafe {