diff options
author | Ivan Tham | 2022-04-05 00:43:14 +0000 |
---|---|---|
committer | GitHub | 2022-04-05 00:43:14 +0000 |
commit | 6fc6f87260a2f11a892f09678fc6c10b01e88e3f (patch) | |
tree | 907085e5b57a1889a3dcd62264e8184a98407571 /helix-core/src/movement.rs | |
parent | e7beb32fd7b9262e61dad96fdf4b36ebdc5367f7 (diff) |
Fix next paragraph logic over muliple blank lines (#1951)
Fix #1928
Diffstat (limited to 'helix-core/src/movement.rs')
-rw-r--r-- | helix-core/src/movement.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs index 3f3ffa35..e695bf94 100644 --- a/helix-core/src/movement.rs +++ b/helix-core/src/movement.rs @@ -202,7 +202,8 @@ pub fn move_next_paragraph( let last_char = prev_grapheme_boundary(slice, slice.line_to_char(line + 1)) == range.cursor(slice); let curr_line_empty = rope_is_line_ending(slice.line(line)); - let next_line_empty = rope_is_line_ending(slice.line(line.saturating_sub(1))); + let next_line_empty = + rope_is_line_ending(slice.line(slice.len_lines().saturating_sub(1).min(line + 1))); let curr_empty_to_line = curr_line_empty && !next_line_empty; // skip character after paragraph boundary @@ -1364,6 +1365,14 @@ mod test { "here\n\nhave\n#[m|]#ultiple\nparagraph\n\n\n\n\n", "here\n\nhave\n#[multiple\nparagraph\n\n\n\n\n|]#", ), + ( + "#[t|]#ext\n\n\nafter two blank lines\n\nmore text\n", + "#[text\n\n\n|]#after two blank lines\n\nmore text\n", + ), + ( + "#[text\n\n\n|]#after two blank lines\n\nmore text\n", + "text\n\n\n#[after two blank lines\n\n|]#more text\n", + ), ]; for (before, expected) in tests { |