@@ -1825,8 +1825,16 @@ fn open(cx: &mut Context, open: Open) {
18251825 Open::Above => line,
18261826 };
18271827
1828− // insert newlines after this index for both Above and Below variants
1829− let line_end_index = line_end_char_index(&doc.text().slice(..), line.saturating_sub(1));
1828+ // Index to insert newlines after, as well as the char width
1829+ // to use to compensate for those inserted newlines.
1830+ let (line_end_index, line_end_offset_width) = if line == 0 {
1831+ (0, 0)
1832+ } else {
1833+ (
1834+ line_end_char_index(&doc.text().slice(..), line.saturating_sub(1)),
1835+ doc.line_ending.len_chars(),
1836+ )
1837+ };
18301838
18311839 // TODO: share logic with insert_newline for indentation
18321840 let indent_level = indent::suggested_indent_for_pos(
@@ -1844,11 +1852,7 @@ fn open(cx: &mut Context, open: Open) {
18441852 let text = text.repeat(count);
18451853
18461854 // calculate new selection ranges
1847− let pos = if line == 0 {
1848− 0 // Required since text will have a min len of 1 (\n)
1849− } else {
1850− offs + line_end_index + 1
1851− };
1855+ let pos = offs + line_end_index + line_end_offset_width;
18521856 for i in 0..count {
18531857 // pos -> beginning of reference line,
18541858 // + (i * (1+indent_len)) -> beginning of i'th line from pos