From 02fe4376220664479aadfb943f0314712d82ac33 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Mon, 7 Jul 2025 16:41:16 -0600 Subject: [PATCH] Fix off by one error when opening multiple new lines with CRLF line endings (#13905) --- helix-term/src/commands.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 38e52e18c..304dcd884 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, )); }