Fix big_word_left_index (#609)

* Fix big_word_left_index

* add one more test

---------

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
nibon7 2023-07-21 04:12:24 +08:00 committed by GitHub
parent 12c6b7d3c7
commit e2543f0790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -493,6 +493,7 @@ mod test {
#[case("abc def ghi", 11, "abc def ")]
#[case("abc def-ghi", 11, "abc ")]
#[case("abc def.ghi", 11, "abc ")]
#[case("abc def gh ", 11, "abc def ")]
fn test_cut_big_word_left(
#[case] input: &str,
#[case] position: usize,

View File

@ -276,7 +276,13 @@ impl LineBuffer {
match (last_word_index, is_whitespace_str(word)) {
(None, true) => None,
(None, false) => Some(i),
(Some(_), true) => None,
(Some(v), true) => {
if is_whitespace_str(&self.lines[i..self.insertion_point]) {
Some(v)
} else {
None
}
}
(Some(v), false) => Some(v),
}
})
@ -1467,6 +1473,7 @@ mod test {
#[case("abc def ghi", 10, 8)]
#[case("abc def-ghi", 10, 4)]
#[case("abc def.ghi", 10, 4)]
#[case("abc def i", 10, 4)]
fn test_big_word_left_index(
#[case] input: &str,
#[case] position: usize,