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
This commit is contained in:
Thanabodee Charoenpiriyakij 2021-11-25 09:02:51 +07:00 committed by GitHub
parent 95f392b18d
commit e8f800a141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2485,6 +2485,10 @@ pub(super) fn goto_line_number(
args: &[&str],
_event: PromptEvent,
) -> anyhow::Result<()> {
if args.is_empty() {
bail!("Line number required");
}
let line = args[0].parse::<usize>()?;
goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));