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) {
|
fn save(&mut self) {
|
||||||
|
let mut filename_new = false;
|
||||||
if self.path.is_none() {
|
if self.path.is_none() {
|
||||||
self.path = read_line("Enter path: ").map(|s| env::current_dir().unwrap().join(s));
|
self.path = read_line("Enter path: ").map(|s| env::current_dir().unwrap().join(s));
|
||||||
|
filename_new = true;
|
||||||
}
|
}
|
||||||
if let Some(path) = &self.path {
|
if let Some(path) = &self.path {
|
||||||
match File::create(path) {
|
match File::create(path) {
|
||||||
|
@ -459,7 +461,9 @@ impl Editor {
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
self.message(format!("Could not save file as '{}': {e}", path.display()));
|
self.message(format!("Could not save file as '{}': {e}", path.display()));
|
||||||
self.path = None;
|
if filename_new {
|
||||||
|
self.path = None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,9 +211,7 @@ impl Navigator {
|
||||||
self.path = new_path;
|
self.path = new_path;
|
||||||
self.selected = self.editors.len();
|
self.selected = self.editors.len();
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => self.message(format!("Could not navigate to directory: {err}")),
|
||||||
self.message(format!("Could not navigate to directory: {err}"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue