@@ -1826,10 +1826,11 @@ fn open(cx: &mut Context, open: Open) {
18261826 };
18271827
18281828 // insert newlines after this index for both Above and Below variants
1829− let linend_index = doc.text().line_to_char(line)
1830− - get_line_ending(&doc.text().line(line))
1829+ let linend_index = doc.text().line_to_char(line).saturating_sub(
1830+ get_line_ending(&doc.text().line(line))
18311831 .map(|le| le.len_chars())
1832− .unwrap_or(0);
1832+ .unwrap_or(0),
1833+ );
18331834
18341835 // TODO: share logic with insert_newline for indentation
18351836 let indent_level = indent::suggested_indent_for_pos(