diff options
author | Blaž Hrastnik | 2021-11-21 11:06:45 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-11-21 11:06:45 +0000 |
commit | d1854d8e6af07cd78ab6c24c859a4471afb3514e (patch) | |
tree | 301e4212e7fc88dd5f626f884bd78b700cf3e4a6 /helix-core/src/textobject.rs | |
parent | 8b85903116fdfdc177bf2ca171831674144de70a (diff) | |
parent | b95c9470de9f9199f109fdbfb6ec9a951fbe8866 (diff) |
Merge remote-tracking branch 'origin/master' into debug
Diffstat (limited to 'helix-core/src/textobject.rs')
-rw-r--r-- | helix-core/src/textobject.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/helix-core/src/textobject.rs b/helix-core/src/textobject.rs index 975ed115..24f063d4 100644 --- a/helix-core/src/textobject.rs +++ b/helix-core/src/textobject.rs @@ -10,7 +10,7 @@ use crate::surround; use crate::syntax::LanguageConfiguration; use crate::Range; -fn find_word_boundary(slice: RopeSlice, mut pos: usize, direction: Direction) -> usize { +fn find_word_boundary(slice: RopeSlice, mut pos: usize, direction: Direction, long: bool) -> usize { use CharCategory::{Eol, Whitespace}; let iter = match direction { @@ -33,7 +33,7 @@ fn find_word_boundary(slice: RopeSlice, mut pos: usize, direction: Direction) -> match categorize_char(ch) { Eol | Whitespace => return pos, category => { - if category != prev_category && pos != 0 && pos != slice.len_chars() { + if !long && category != prev_category && pos != 0 && pos != slice.len_chars() { return pos; } else { match direction { @@ -70,13 +70,14 @@ pub fn textobject_word( range: Range, textobject: TextObject, _count: usize, + long: bool, ) -> Range { let pos = range.cursor(slice); - let word_start = find_word_boundary(slice, pos, Direction::Backward); + let word_start = find_word_boundary(slice, pos, Direction::Backward, long); let word_end = match slice.get_char(pos).map(categorize_char) { None | Some(CharCategory::Whitespace | CharCategory::Eol) => pos, - _ => find_word_boundary(slice, pos + 1, Direction::Forward), + _ => find_word_boundary(slice, pos + 1, Direction::Forward, long), }; // Special case. @@ -268,7 +269,7 @@ mod test { let slice = doc.slice(..); for &case in scenario { let (pos, objtype, expected_range) = case; - let result = textobject_word(slice, Range::point(pos), objtype, 1); + let result = textobject_word(slice, Range::point(pos), objtype, 1, false); assert_eq!( result, expected_range.into(), |