forked from helix-editor/helix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It seemed to panic when I pressed too many times, but that is from lsp side.
- Loading branch information
Showing
5 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use crate::movement::{categorize, is_horiz_blank, is_word, skip_over_prev}; | ||
use ropey::RopeSlice; | ||
|
||
#[must_use] | ||
pub fn nth_prev_word_boundary(slice: RopeSlice, mut char_idx: usize, count: usize) -> usize { | ||
let mut with_end = false; | ||
|
||
for _ in 0..count { | ||
if char_idx == 0 { | ||
break; | ||
} | ||
|
||
// return if not skip while? | ||
skip_over_prev(slice, &mut char_idx, |ch| ch == '\n'); | ||
|
||
with_end = skip_over_prev(slice, &mut char_idx, is_horiz_blank); | ||
|
||
// refetch | ||
let ch = slice.char(char_idx); | ||
|
||
if is_word(ch) { | ||
with_end = skip_over_prev(slice, &mut char_idx, is_word); | ||
} else if ch.is_ascii_punctuation() { | ||
with_end = skip_over_prev(slice, &mut char_idx, |ch| ch.is_ascii_punctuation()); | ||
} | ||
} | ||
|
||
if with_end { | ||
char_idx | ||
} else { | ||
char_idx + 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters