Skip to content

Commit

Permalink
Fix next paragraph logic over muliple blank lines (#1951)
Browse files Browse the repository at this point in the history
Fix #1928
  • Loading branch information
pickfire authored Apr 5, 2022
1 parent e7beb32 commit 6fc6f87
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion helix-core/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6fc6f87

Please sign in to comment.