Unnamed repository; edit this file 'description' to name the repository.
Fix off by one error when opening multiple new lines with CRLF line endings (#13905)
Andrew Davis 8 months ago
parent e88e48f · commit 02fe437
-rw-r--r--helix-term/src/commands.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 38e52e18..304dcd88 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -3726,11 +3726,13 @@ fn open(cx: &mut Context, open: Open, comment_continuation: CommentContinuation)
.map(|token| token.len() + 1) // `+ 1` for the extra space added
.unwrap_or_default();
for i in 0..count {
- // pos -> beginning of reference line,
- // + (i * (1+indent_len + comment_len)) -> beginning of i'th line from pos (possibly including comment token)
+ // pos -> beginning of reference line,
+ // + (i * (line_ending_len + indent_len + comment_len)) -> beginning of i'th line from pos (possibly including comment token)
// + indent_len + comment_len -> -> indent for i'th line
ranges.push(Range::point(
- pos + (i * (1 + indent_len + comment_len)) + indent_len + comment_len,
+ pos + (i * (doc.line_ending.len_chars() + indent_len + comment_len))
+ + indent_len
+ + comment_len,
));
}