@@ -5,7 +5,7 @@ use helix_core::{
55 object, pos_at_coords,
66 regex::{self, Regex},
77 register::{self, Register, Registers},
8− search, selection, Change, ChangeSet, LineEnding, Position, Range, Rope, RopeSlice, Selection,
8+ search, selection, Change, ChangeSet, LineEnding, Position, Range, Rope, RopeSlice, Selection, get_line_ending,
99 SmallVec, Tendril, Transaction,
1010};
1111
@@ -183,11 +183,10 @@ pub fn move_line_end(cx: &mut Context) {
183183 let text = doc.text();
184184 let line = text.char_to_line(range.head);
185185
186− // Line end is pos at the start of next line - 1
187− // subtract another 1 because the line ends with \n
188186 let pos = text
189187 .line_to_char(line + 1)
190− .saturating_sub(doc.line_ending().len() + 1);
188+ .saturating_sub(get_line_ending(&text.line(line)).map(|le| le.len_chars()).unwrap_or(0));
189+
191190 Range::new(pos, pos)
192191 });
193192
@@ -607,11 +606,10 @@ pub fn extend_line_end(cx: &mut Context) {
607606 let text = doc.text();
608607 let line = text.char_to_line(range.head);
609608
610− // Line end is pos at the start of next line - 1
611− // subtract another 1 because the line ends with \n
612609 let pos = text
613610 .line_to_char(line + 1)
614− .saturating_sub(doc.line_ending().len() + 1);
611+ .saturating_sub(get_line_ending(&text.line(line)).map(|le| le.len_chars()).unwrap_or(0));
612+
615613 Range::new(range.anchor, pos)
616614 });
617615