@@ -1826,18 +1826,14 @@ fn open(cx: &mut Context, open: Open) {
1828 // insert newlines after this index for both Above and Below variants
1828 // insert newlines after this index for both Above and Below variants
1829− let linend_index = doc.text().line_to_char(line).saturating_sub(
1829+ let line_end_index = rope_end_without_line_ending(&doc.text().slice(..));
1830− get_line_ending(&doc.text().line(line))
1831− .map(|le| le.len_chars())
1835 // TODO: share logic with insert_newline for indentation
1831 // TODO: share logic with insert_newline for indentation
1836 let indent_level = indent::suggested_indent_for_pos(
1832 let indent_level = indent::suggested_indent_for_pos(
1837 doc.language_config(),
1833 doc.language_config(),
1838 doc.syntax(),
1834 doc.syntax(),
1840− linend_index,
1836+ line_end_index,
1843 let indent = doc.indent_unit().repeat(indent_level);
1839 let indent = doc.indent_unit().repeat(indent_level);
@@ -1851,7 +1847,7 @@ fn open(cx: &mut Context, open: Open) {
1851 let pos = if line == 0 {
1847 let pos = if line == 0 {
1852 0 // Required since text will have a min len of 1 (\n)
1848 0 // Required since text will have a min len of 1 (\n)
1853 } else {
1849 } else {
1854− offs + linend_index + 1
1850+ offs + line_end_index + 1
1856 for i in 0..count {
1852 for i in 0..count {
1857 // pos -> beginning of reference line,
1853 // pos -> beginning of reference line,
@@ -1862,7 +1858,7 @@ fn open(cx: &mut Context, open: Open) {
1863 offs += text.chars().count();
1859 offs += text.chars().count();
1865− (linend_index, linend_index, Some(text.into()))
1861+ (line_end_index, line_end_index, Some(text.into()))
1868 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));
1864 transaction = transaction.with_selection(Selection::new(ranges, selection.primary_index()));