on master help sign in
Don't crash if no filename specified on open
d8e1655Blaž Hrastnik
helix-term/src/commands.rs+9−2
@@ -885,8 +885,15 @@ mod cmd {
885 }
885 }
886
886
887 fn open(editor: &mut Editor, args: &[&str], event: PromptEvent) {
887 fn open(editor: &mut Editor, args: &[&str], event: PromptEvent) {
888− let path = args[0];
888+ match args.get(0) {
889+ Some(path) => {
890+ // TODO: handle error
889− editor.open(path.into(), Action::Replace);
891+ editor.open(path.into(), Action::Replace);
892+ }
893+ None => {
894+ editor.set_error("wrong argument count".to_string());
895+ }
896+ };
890 }
897 }
891
898
892 fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {
899 fn write(editor: &mut Editor, args: &[&str], event: PromptEvent) {