Skip to content

Commit

Permalink
fix: always subtract the correct amount
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-rev committed Jan 13, 2025
1 parent 6bdd187 commit 903b10d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4070,9 +4070,7 @@ pub mod insert {
// Note that `first_trailing_whitespace_char` is at least `pos` so the
// unsigned subtraction (`pos - first_trailing_whitespace_char`) cannot
// underflow.
local_offs as isize
- (pos + if ranges.is_empty() { 0 } else { 1 }
- first_trailing_whitespace_char) as isize,
local_offs as isize - (pos - first_trailing_whitespace_char) as isize,
)
} else {
// If the current line is all whitespace, insert a line ending at the beginning of
Expand All @@ -4083,6 +4081,8 @@ pub mod insert {
(line_start, line_start, new_text.chars().count() as isize)
};

let local_offs = local_offs - if ranges.is_empty() { 0 } else { 1 };

let new_range = if range.cursor(text) > range.anchor {
// when appending, extend the range by local_offs
Range::new(
Expand Down

0 comments on commit 903b10d

Please sign in to comment.