Non-existent directory new file
This commit is contained in:
parent
d4e20b1063
commit
4b5579c726
4 changed files with 18 additions and 7 deletions
|
|
@ -25,5 +25,4 @@
|
|||
|
||||
## Issues to fix
|
||||
|
||||
- New file creation should work with non-existent directories
|
||||
- Undo history changes should not join so easily
|
||||
|
|
@ -223,10 +223,11 @@ impl Buffer {
|
|||
}
|
||||
|
||||
pub fn save(&mut self) -> Result<(), Error> {
|
||||
std::fs::write(
|
||||
self.path.as_ref().expect("buffer must have path to save"),
|
||||
self.text.to_string(),
|
||||
)?;
|
||||
let path = self.path.as_ref().expect("buffer must have path to save");
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
std::fs::write(path, self.text.to_string())?;
|
||||
self.diverged = false;
|
||||
self.opened_at = Some(SystemTime::now());
|
||||
self.unsaved = false;
|
||||
|
|
|
|||
|
|
@ -407,7 +407,18 @@ impl Opener {
|
|||
}
|
||||
})
|
||||
}
|
||||
Err(err) => self.options.set_options::<_, ()>(Vec::new(), |_| None),
|
||||
Err(err) => self.options.set_options(
|
||||
if filter != "" {
|
||||
vec![FileOption {
|
||||
path: [dir, &file_name].into_iter().collect(),
|
||||
kind: FileKind::New,
|
||||
is_link: false,
|
||||
}]
|
||||
} else {
|
||||
Vec::new()
|
||||
},
|
||||
|_| Some(()),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ impl Visual for SearchResult {
|
|||
frame
|
||||
.rect([0, 0], [col_a, !0])
|
||||
.with_fg(state.theme.option_file)
|
||||
.text([0, 0], &format!("{name}:{}", self.loc.line_idx + 1));
|
||||
.text([0, 0], &name);
|
||||
// Path
|
||||
frame
|
||||
.rect([col_a, 0], [col_b, !0])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue