on master help sign in
Don't crash if no filename specified on open
commitd8e16554bf0478e30853e8950132a2d17dba5a17 authorBlaž Hrastnik <blaz@mxxn.io> dateTue 1 Jun 2021, 11:59 (5 years ago) parent2cc30cd
1 file changed+9−2
helix-term/src/commands.rs+9−2
helix-term/src/commands.rs+9−2
@@ -885,8 +885,15 @@ mod cmd {
885885 }
886886
887887 fn open(editor: &mut Editor, args: &[&str], event: PromptEvent) {
888− let path = args[0];
889− editor.open(path.into(), Action::Replace);
888+ match args.get(0) {
889+ Some(path) => {
890+ // TODO: handle error
891+ editor.open(path.into(), Action::Replace);
892+ }
893+ None => {
894+ editor.set_error("wrong argument count".to_string());
895+ }
896+ };
890897 }
891898
892899 fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {