summaryrefslogtreecommitdiff
path: root/helix-core/src/movement.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-02 02:37:28 +0000
committerNathan Vegdahl2021-07-02 02:37:28 +0000
commit2224a1527ec9592f16131b0aa3923fc3d37592e7 (patch)
tree2a08b053cb32cef9dc1db5895778d419ebaebb5b /helix-core/src/movement.rs
parente725957704274b1ec814a34ddf6f75faf35358e7 (diff)
parent9f62ad0715240156b512dfc7c584d2d0df05a664 (diff)
Merge branch 'master' into great_line_ending_and_cursor_range_cleanup
Diffstat (limited to 'helix-core/src/movement.rs')
-rw-r--r--helix-core/src/movement.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs
index a4c7f9c9..acc95e7e 100644
--- a/helix-core/src/movement.rs
+++ b/helix-core/src/movement.rs
@@ -1,12 +1,9 @@
-use std::iter::{self, from_fn, Peekable, SkipWhile};
+use std::iter::{self, from_fn};
use ropey::iter::Chars;
use crate::{
- chars::{
- categorize_char, char_is_line_ending, char_is_punctuation, char_is_whitespace,
- char_is_word, CharCategory,
- },
+ chars::{categorize_char, char_is_line_ending, CharCategory},
coords_at_pos,
graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary},
line_ending::{get_line_ending, line_end_char_index},
@@ -116,7 +113,7 @@ pub fn move_prev_long_word_start(slice: RopeSlice, range: Range, count: usize) -
word_move(slice, range, count, WordMotionTarget::PrevLongWordStart)
}
-fn word_move(slice: RopeSlice, mut range: Range, count: usize, target: WordMotionTarget) -> Range {
+fn word_move(slice: RopeSlice, range: Range, count: usize, target: WordMotionTarget) -> Range {
(0..count).fold(range, |range, _| {
slice.chars_at(range.head).range_to_target(target, range)
})
@@ -182,7 +179,6 @@ enum WordMotionPhase {
impl CharHelpers for Chars<'_> {
fn range_to_target(&mut self, target: WordMotionTarget, origin: Range) -> Range {
- let range = origin;
// Characters are iterated forward or backwards depending on the motion direction.
let characters: Box<dyn Iterator<Item = char>> = match target {
WordMotionTarget::PrevWordStart | WordMotionTarget::PrevLongWordStart => {
@@ -270,20 +266,20 @@ fn reached_target(target: WordMotionTarget, peek: char, next_peek: Option<&char>
match target {
WordMotionTarget::NextWordStart => {
- (is_word_boundary(peek, *next_peek)
- && (char_is_line_ending(*next_peek) || !next_peek.is_whitespace()))
+ is_word_boundary(peek, *next_peek)
+ && (char_is_line_ending(*next_peek) || !next_peek.is_whitespace())
}
WordMotionTarget::NextWordEnd | WordMotionTarget::PrevWordStart => {
- (is_word_boundary(peek, *next_peek)
- && (!peek.is_whitespace() || char_is_line_ending(*next_peek)))
+ is_word_boundary(peek, *next_peek)
+ && (!peek.is_whitespace() || char_is_line_ending(*next_peek))
}
WordMotionTarget::NextLongWordStart => {
- (is_long_word_boundary(peek, *next_peek)
- && (char_is_line_ending(*next_peek) || !next_peek.is_whitespace()))
+ is_long_word_boundary(peek, *next_peek)
+ && (char_is_line_ending(*next_peek) || !next_peek.is_whitespace())
}
WordMotionTarget::NextLongWordEnd | WordMotionTarget::PrevLongWordStart => {
- (is_long_word_boundary(peek, *next_peek)
- && (!peek.is_whitespace() || char_is_line_ending(*next_peek)))
+ is_long_word_boundary(peek, *next_peek)
+ && (!peek.is_whitespace() || char_is_line_ending(*next_peek))
}
}
}