From 9156f5cf47aca09f074e9819321c683d55cd0d91 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 11 Jan 2015 01:25:23 -0800 Subject: [PATCH] Passing a filename that doesn't exist will now open a buffer that will be saved to a new file of that name. --- src/editor.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/editor.rs b/src/editor.rs index e3c9f70..9b0b0b1 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -63,7 +63,10 @@ impl Editor { } pub fn new_from_file(path: &Path) -> Editor { - let buf = load_file_to_buffer(path).unwrap(); + let buf = match load_file_to_buffer(path) { + Ok(b) => {b}, + _ => {Buffer::new()} + }; let mut ed = Editor { buffer: buf,