diff --git a/src/io/file.rs b/src/io/file.rs index 2679b95c14df3cef3668f9f928bbaca79d583d47..63b435434bc0b31fb4fe1b97f0fcfac2d4edaaa9 100644 --- a/src/io/file.rs +++ b/src/io/file.rs @@ -37,8 +37,11 @@ impl Editor { } /// Write the file. - pub fn write(&mut self, path: &str) -> FileStatus { + pub fn write<'a> (&'a mut self, mut path: &'a str) -> FileStatus { self.buffers.current_buffer_info_mut().title = Some(path.into()); + if path == "" { + path = self.files[0].as_str(); + } if let Some(mut file) = File::create(path).ok() { if file.write(self.buffers.current_buffer().to_string().as_bytes()) .is_ok() diff --git a/src/state/editor.rs b/src/state/editor.rs index 2527a3be3ebbd928c3dff26bbe96f66d75213600..7ea4dbd795a8883bad539e38f7830feb7e1cfe58 100644 --- a/src/state/editor.rs +++ b/src/state/editor.rs @@ -185,6 +185,8 @@ pub struct Editor { pub char_width: usize, /// The character height in pixels pub char_height: usize, + /// The files currently open + pub files: Vec<String>, } impl Editor { @@ -207,6 +209,7 @@ impl Editor { previous_instruction: None, char_width: 8, char_height: 16, + files: Vec::new(), }; #[cfg(not(feature = "orbital"))] @@ -221,6 +224,7 @@ impl Editor { previous_instruction: None, char_width: 8, char_height: 16, + files: Vec::new(), }; let mut files: Vec<String> = Vec::new(); @@ -264,6 +268,7 @@ impl Editor { for file in args_iter { files.push(file); } + editor.files = files.clone(); break; } _ => { @@ -291,6 +296,7 @@ impl Editor { } files.push(arg); + editor.files = files.clone() } } }