fix: Don't panic on Enter on an empty document.

Refs #386
This commit is contained in:
Blaž Hrastnik 2021-06-28 17:52:38 +09:00
parent ca98210d20
commit 6214d707f3

View File

@ -2511,7 +2511,7 @@ pub fn insert_newline(cx: &mut Context) {
} else {
contents.char(pos - 1)
};
let curr = contents.char(pos);
let curr = contents.get_char(pos).unwrap_or(' ');
// TODO: offset range.head by 1? when calculating?
let indent_level = indent::suggested_indent_for_pos(