@@ -1,6 +1,6 @@
1use helix_core::{
1use helix_core::{
2 comment, coords_at_pos, find_first_non_whitespace_char, find_root, get_line_ending, graphemes,
2 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,
4 movement::{self, Direction},
4 movement::{self, Direction},
5 object, pos_at_coords,
5 object, pos_at_coords,
6 regex::{self, Regex},
6 regex::{self, Regex},
@@ -342,11 +342,7 @@ fn move_line_end(cx: &mut Context) {
342 let text = doc.text();
342 let text = doc.text();
343 let line = text.char_to_line(range.head);
343 let line = text.char_to_line(range.head);
345− let pos = text.line_to_char(line + 1).saturating_sub(
345+ let pos = line_end(&text.slice(..), line);
346− get_line_ending(&text.line(line))
347− .map(|le| le.len_chars())
351 Range::new(pos, pos)
347 Range::new(pos, pos)
@@ -767,11 +763,7 @@ fn extend_line_end(cx: &mut Context) {
767 let text = doc.text();
763 let text = doc.text();
768 let line = text.char_to_line(range.head);
764 let line = text.char_to_line(range.head);
770− let pos = text.line_to_char(line + 1).saturating_sub(
766+ let pos = line_end(&text.slice(..), line);
771− get_line_ending(&text.line(line))
772− .map(|le| le.len_chars())
776 Range::new(range.anchor, pos)
768 Range::new(range.anchor, pos)
@@ -1650,12 +1642,7 @@ fn append_to_line(cx: &mut Context) {
1650 let selection = doc.selection(view.id).transform(|range| {
1642 let selection = doc.selection(view.id).transform(|range| {
1651 let text = doc.text();
1643 let text = doc.text();
1652 let line = text.char_to_line(range.head);
1644 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
1645+ let pos = line_end(&text.slice(..), line);
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())
1659 Range::new(pos, pos)
1646 Range::new(pos, pos)
1661 doc.set_selection(view.id, selection);
1648 doc.set_selection(view.id, selection);