@@ -184,14 +184,10 @@ pub fn move_line_end(cx: &mut Context) {
184184 let line = text.char_to_line(range.head);
185185
186186 // Line end is pos at the start of next line - 1
187− // subtract 3 if the line ending is \r\n, otherwise subtract 2 as I assume all others are just 1 char length
188− let pos =
189− text.line_to_char(line + 1)
190− .saturating_sub(if doc.line_ending == LineEnding::Crlf {
191− 3
192− } else {
193− 2
194− });
187+ // subtract another 1 because the line ends with \n
188+ let pos = text
189+ .line_to_char(line + 1)
190+ .saturating_sub(doc.line_ending().len() + 1);
195191 Range::new(pos, pos)
196192 });
197193
@@ -612,14 +608,10 @@ pub fn extend_line_end(cx: &mut Context) {
612608 let line = text.char_to_line(range.head);
613609
614610 // Line end is pos at the start of next line - 1
615− // subtract 3 if the line ending is \r\n, otherwise subtract 2 as I assume all others are just 1 char length
616− let pos =
617− text.line_to_char(line + 1)
618− .saturating_sub(if doc.line_ending == LineEnding::Crlf {
619− 3
620− } else {
621− 2
622− });
611+ // subtract another 1 because the line ends with \n
612+ let pos = text
613+ .line_to_char(line + 1)
614+ .saturating_sub(doc.line_ending().len() + 1);
623615 Range::new(range.anchor, pos)
624616 });
625617
@@ -908,7 +900,7 @@ pub fn append_mode(cx: &mut Context) {
908900 if selection.iter().any(|range| range.head == end) {
909901 let transaction = Transaction::change(
910902 doc.text(),
911− std::array::IntoIter::new([(end, end, Some(Tendril::from_char('\n')))]), // TODO: change \n to doc.line_ending()
903+ std::array::IntoIter::new([(end, end, Some(doc.line_ending().as_str().into()))]),
912904 );
913905 doc.apply(&transaction, view.id);
914906 }
@@ -1535,7 +1527,7 @@ fn open(cx: &mut Context, open: Open) {
15351527 );
15361528 let indent = doc.indent_unit().repeat(indent_level);
15371529 let mut text = String::with_capacity(1 + indent.len());
1538− text.push_str(doc.line_ending());
1530+ text.push_str(doc.line_ending().as_str());
15391531 text.push_str(&indent);
15401532 let text = text.repeat(count);
15411533
@@ -2143,7 +2135,7 @@ pub mod insert {
21432135 );
21442136 let indent = doc.indent_unit().repeat(indent_level);
21452137 let mut text = String::with_capacity(1 + indent.len());
2146− text.push_str(doc.line_ending());
2138+ text.push_str(doc.line_ending().as_str());
21472139 text.push_str(&indent);
21482140
21492141 let head = pos + offs + text.chars().count();
@@ -2164,7 +2156,7 @@ pub mod insert {
21642156 if helix_core::auto_pairs::PAIRS.contains(&(prev, curr)) {
21652157 // another newline, indent the end bracket one level less
21662158 let indent = doc.indent_unit().repeat(indent_level.saturating_sub(1));
2167− text.push_str(doc.line_ending());
2159+ text.push_str(doc.line_ending().as_str());
21682160 text.push_str(&indent);
21692161 }
21702162
@@ -2283,7 +2275,7 @@ fn paste_impl(
22832275 // if any of values ends \n it's linewise paste
22842276 let linewise = values
22852277 .iter()
2286− .any(|value| value.ends_with(doc.line_ending()));
2278+ .any(|value| value.ends_with(doc.line_ending().as_str()));
22872279
22882280 let mut values = values.iter().cloned().map(Tendril::from).chain(repeat);
22892281