Skip to content

Commit

Permalink
Fix big_word_left_index (#609)
Browse files Browse the repository at this point in the history
* Fix big_word_left_index

* add one more test

---------

Co-authored-by: sholderbach <[email protected]>
  • Loading branch information
nibon7 and sholderbach authored Jul 20, 2023
1 parent 12c6b7d commit e2543f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core_editor/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion src/core_editor/line_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
})
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e2543f0

Please sign in to comment.