@@ -1,6 +1,6 @@
11use helix_core::{
22 comment, coords_at_pos, find_first_non_whitespace_char, find_root, get_line_ending, graphemes,
3− indent, match_brackets,
3+ indent, line_end, match_brackets,
44 movement::{self, Direction},
55 object, pos_at_coords,
66 regex::{self, Regex},
@@ -342,11 +342,7 @@ fn move_line_end(cx: &mut Context) {
342342 let text = doc.text();
343343 let line = text.char_to_line(range.head);
344344
345− let pos = text.line_to_char(line + 1).saturating_sub(
346− get_line_ending(&text.line(line))
347− .map(|le| le.len_chars())
348− .unwrap_or(0),
349− );
345+ let pos = line_end(&text.slice(..), line);
350346
351347 Range::new(pos, pos)
352348 });
@@ -767,11 +763,7 @@ fn extend_line_end(cx: &mut Context) {
767763 let text = doc.text();
768764 let line = text.char_to_line(range.head);
769765
770− let pos = text.line_to_char(line + 1).saturating_sub(
771− get_line_ending(&text.line(line))
772− .map(|le| le.len_chars())
773− .unwrap_or(0),
774− );
766+ let pos = line_end(&text.slice(..), line);
775767
776768 Range::new(range.anchor, pos)
777769 });
@@ -1650,12 +1642,7 @@ fn append_to_line(cx: &mut Context) {
16501642 let selection = doc.selection(view.id).transform(|range| {
16511643 let text = doc.text();
16521644 let line = text.char_to_line(range.head);
1653− // we can't use line_to_char(line + 1) - 2 because the last line might not contain a newline
1654− let pos = (text.line_to_char(line) + text.line(line).len_chars()).saturating_sub(
1655− get_line_ending(&text.line(line))
1656− .map(|le| le.len_chars())
1657− .unwrap_or(0),
1658− );
1645+ let pos = line_end(&text.slice(..), line);
16591646 Range::new(pos, pos)
16601647 });
16611648 doc.set_selection(view.id, selection);