Skip to content

Commit

Permalink
Apply clippy lints on textobject
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin committed Jul 2, 2021
1 parent 94e2f3b commit 8da02fe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
10 changes: 6 additions & 4 deletions helix-core/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Iterator<Item = char>> = match target {
WordMotionTarget::PrevWordStart | WordMotionTarget::PrevLongWordStart | WordMotionTarget::PrevWordEnd => {
WordMotionTarget::PrevWordStart
| WordMotionTarget::PrevLongWordStart
| WordMotionTarget::PrevWordEnd => {
self.next();
Box::new(from_fn(|| self.prev()))
}
Expand All @@ -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,
};

Expand Down
15 changes: 3 additions & 12 deletions helix-core/src/textobject.rs
Original file line number Diff line number Diff line change
@@ -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)
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8da02fe

Please sign in to comment.