only reset filename when failing to save if it was set by the user (don't convert read-only opened files to 'untitled')
This commit is contained in:
parent
5035e4c295
commit
2b01ff226d
2 changed files with 6 additions and 4 deletions
|
@ -447,8 +447,10 @@ impl Editor {
|
|||
}
|
||||
|
||||
fn save(&mut self) {
|
||||
let mut filename_new = false;
|
||||
if self.path.is_none() {
|
||||
self.path = read_line("Enter path: ").map(|s| env::current_dir().unwrap().join(s));
|
||||
filename_new = true;
|
||||
}
|
||||
if let Some(path) = &self.path {
|
||||
match File::create(path) {
|
||||
|
@ -459,12 +461,14 @@ impl Editor {
|
|||
}
|
||||
Err(e) => {
|
||||
self.message(format!("Could not save file as '{}': {e}", path.display()));
|
||||
if filename_new {
|
||||
self.path = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn color_selection() {
|
||||
queue!(stdout(), SetColors(Colors::new(Color::Black, Color::White))).unwrap();
|
||||
|
|
|
@ -211,9 +211,7 @@ impl Navigator {
|
|||
self.path = new_path;
|
||||
self.selected = self.editors.len();
|
||||
}
|
||||
Err(err) => {
|
||||
self.message(format!("Could not navigate to directory: {err}"));
|
||||
}
|
||||
Err(err) => self.message(format!("Could not navigate to directory: {err}")),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue