From 8da02fe7b06f0487bb4833f1ac0b0c5ff517ca1b Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Fri, 2 Jul 2021 19:13:03 +0530 Subject: [PATCH] Apply clippy lints on textobject --- helix-core/src/movement.rs | 10 ++++++---- helix-core/src/textobject.rs | 15 +++------------ helix-term/src/commands.rs | 2 +- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs index a3232fa9abb1..f9e5deb4a385 100644 --- a/helix-core/src/movement.rs +++ b/helix-core/src/movement.rs @@ -186,7 +186,9 @@ impl CharHelpers for Chars<'_> { fn range_to_target(&mut self, target: WordMotionTarget, origin: Range) -> Range { // Characters are iterated forward or backwards depending on the motion direction. let characters: Box> = match target { - WordMotionTarget::PrevWordStart | WordMotionTarget::PrevLongWordStart | WordMotionTarget::PrevWordEnd => { + WordMotionTarget::PrevWordStart + | WordMotionTarget::PrevLongWordStart + | WordMotionTarget::PrevWordEnd => { self.next(); Box::new(from_fn(|| self.prev())) } @@ -195,9 +197,9 @@ impl CharHelpers for Chars<'_> { // Index advancement also depends on the direction. let advance: &dyn Fn(&mut usize) = match target { - WordMotionTarget::PrevWordStart | WordMotionTarget::PrevLongWordStart | WordMotionTarget::PrevWordEnd => { - &|u| *u = u.saturating_sub(1) - } + WordMotionTarget::PrevWordStart + | WordMotionTarget::PrevLongWordStart + | WordMotionTarget::PrevWordEnd => &|u| *u = u.saturating_sub(1), _ => &|u| *u += 1, }; diff --git a/helix-core/src/textobject.rs b/helix-core/src/textobject.rs index e4736af78a21..84b5dcfa9974 100644 --- a/helix-core/src/textobject.rs +++ b/helix-core/src/textobject.rs @@ -1,15 +1,15 @@ -use ropey::{Rope, RopeSlice}; +use ropey::RopeSlice; use crate::chars::{categorize_char, char_is_line_ending, char_is_whitespace, CharCategory}; use crate::movement::{self, Direction}; use crate::surround; use crate::Range; -fn this_word_end_pos(slice: RopeSlice, mut pos: usize) -> usize { +fn this_word_end_pos(slice: RopeSlice, pos: usize) -> usize { this_word_bound_pos(slice, pos, Direction::Forward) } -fn this_word_start_pos(slice: RopeSlice, mut pos: usize) -> usize { +fn this_word_start_pos(slice: RopeSlice, pos: usize) -> usize { this_word_bound_pos(slice, pos, Direction::Backward) } @@ -97,15 +97,6 @@ pub fn textobject_word( Range::new(anchor, head) } -pub fn textobject_paragraph( - slice: RopeSlice, - range: Range, - textobject: TextObject, - count: usize, -) -> Range { - Range::point(0) -} - pub fn textobject_surround( slice: RopeSlice, range: Range, diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 62948ef6421d..2f168e1201ba 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -3507,7 +3507,7 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) { let (view, doc) = current!(cx.editor); let text = doc.text().slice(..); - let selection = doc.selection(view.id).transform(|mut range| { + let selection = doc.selection(view.id).transform(|range| { match ch { 'w' => textobject::textobject_word(text, range, objtype, count), // TODO: cancel new ranges if inconsistent surround matches across lines