on master help sign in
fix: panic on O at the start of the file (fixes #354)
commit655c1aeb73256c2f74abd1d251b04909d8251f37 authorBlaž Hrastnik <blaz@mxxn.io> dateThu 24 Jun 2021, 00:50 (5 years ago) parentea8cd47
1 file changed+4−3
helix-term/src/commands.rs+4−3
helix-term/src/commands.rs+4−3
@@ -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(