on master help sign in
Fix next paragraph logic over muliple blank lines (#1951)
6fc6f87Ivan Tham
helix-core/src/movement.rs+10−1
@@ -202,7 +202,8 @@ pub fn move_next_paragraph(
202 let last_char =
202 let last_char =
203 prev_grapheme_boundary(slice, slice.line_to_char(line + 1)) == range.cursor(slice);
203 prev_grapheme_boundary(slice, slice.line_to_char(line + 1)) == range.cursor(slice);
204 let curr_line_empty = rope_is_line_ending(slice.line(line));
204 let curr_line_empty = rope_is_line_ending(slice.line(line));
205+ let next_line_empty =
205− let next_line_empty = rope_is_line_ending(slice.line(line.saturating_sub(1)));
206+ rope_is_line_ending(slice.line(slice.len_lines().saturating_sub(1).min(line + 1)));
206 let curr_empty_to_line = curr_line_empty && !next_line_empty;
207 let curr_empty_to_line = curr_line_empty && !next_line_empty;
207
208
208 // skip character after paragraph boundary
209 // skip character after paragraph boundary
@@ -1364,6 +1365,14 @@ mod test {
1364 "here\n\nhave\n#[m|]#ultiple\nparagraph\n\n\n\n\n",
1365 "here\n\nhave\n#[m|]#ultiple\nparagraph\n\n\n\n\n",
1365 "here\n\nhave\n#[multiple\nparagraph\n\n\n\n\n|]#",
1366 "here\n\nhave\n#[multiple\nparagraph\n\n\n\n\n|]#",
1366 ),
1367 ),
1368+ (
1369+ "#[t|]#ext\n\n\nafter two blank lines\n\nmore text\n",
1370+ "#[text\n\n\n|]#after two blank lines\n\nmore text\n",
1371+ ),
1372+ (
1373+ "#[text\n\n\n|]#after two blank lines\n\nmore text\n",
1374+ "text\n\n\n#[after two blank lines\n\n|]#more text\n",
1375+ ),
1367 ];
1376 ];
1368
1377
1369 for (before, expected) in tests {
1378 for (before, expected) in tests {