Skip to content

Commit

Permalink
Do not crash when run goto command without line number (#1160)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wingyplus authored Nov 25, 2021
1 parent 95f392b commit e8f800a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>()?;

goto_line_impl(&mut cx.editor, NonZeroUsize::new(line));
Expand Down

0 comments on commit e8f800a

Please sign in to comment.