From 6214d707f3aac89938441171cf7cc0d96517bbe5 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Mon, 28 Jun 2021 17:52:38 +0900 Subject: fix: Don't panic on Enter on an empty document. Refs #386 --- helix-term/src/commands.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 688e653a..f6511ba5 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2511,7 +2511,7 @@ pub mod insert { } 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( -- cgit v1.2.3-70-g09d2