From e8f800a141af11b4f2f4c838cd4fd1f8aa7fa971 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 25 Nov 2021 09:02:51 +0700 Subject: [PATCH] Do not crash when run goto command without line number (#1160) * Do not crash when run goto command without line number Report an error when running goto command without entering a line number. Fixes #1159 * Use is_empty() instead check len zero --- helix-term/src/commands.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index b5b6ac6d..ff8d7a4f 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2485,6 +2485,10 @@ mod cmd { args: &[&str], _event: PromptEvent, ) -> anyhow::Result<()> { + if args.is_empty() { + bail!("Line number required"); + } + let line = args[0].parse::()?; goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));