Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off-by-one in extend_line_above #3689

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
let (start_line, end_line) = range.line_range(text.slice(..));

let start = text.line_to_char(match extend {
Extend::Above => start_line.saturating_sub(count),
Extend::Above => start_line.saturating_sub(count - 1),
Extend::Below => start_line,
});
let end = text.line_to_char(
Expand All @@ -1985,7 +1985,7 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
// extend to previous/next line if current line is selected
let (anchor, head) = if range.from() == start && range.to() == end {
match extend {
Extend::Above => (end, text.line_to_char(start_line.saturating_sub(count + 1))),
Extend::Above => (end, text.line_to_char(start_line.saturating_sub(count))),
Extend::Below => (
start,
text.line_to_char((end_line + count + 1).min(text.len_lines())),
Expand Down