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
commite8f800a141af11b4f2f4c838cd4fd1f8aa7fa971
authorThanabodee Charoenpiriyakij <wingyminus@gmail.com>
dateThu 25 Nov 2021, 09:02 (5 years ago)
parent95f392b
helix-term/src/commands.rs+4
@@ -2485,6 +2485,10 @@ mod cmd {
24852485 args: &[&str],
24862486 _event: PromptEvent,
24872487 ) -> anyhow::Result<()> {
2488+ if args.is_empty() {
2489+ bail!("Line number required");
2490+ }
2491+
24882492 let line = args[0].parse::<usize>()?;
24892493
24902494 goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));