Fix off by one error when opening multiple new lines with CRLF line endings (#13905)

pull/10905/head^2
Andrew Davis 2025-07-07 16:41:16 -06:00 committed by GitHub
parent e88e48f41c
commit 02fe437622
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -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,
));
}