Skip to content

Commit

Permalink
fix: Don't allow moving past last line, fixes #30, #24
Browse files Browse the repository at this point in the history
Off by 1 error
  • Loading branch information
archseer committed Jun 2, 2021
1 parent 22dad59 commit c0264b9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion helix-core/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn move_vertically(

let new_line = match dir {
Direction::Backward => row.saturating_sub(count),
Direction::Forward => std::cmp::min(row.saturating_add(count), text.len_lines() - 1),
Direction::Forward => std::cmp::min(row.saturating_add(count), text.len_lines() - 2),
};

// convert to 0-indexed, subtract another 1 because len_chars() counts \n
Expand Down

0 comments on commit c0264b9

Please sign in to comment.