Add parent folder to file browser

pull/11285/head
Denys Rybalka 4 months ago
parent 8f5e4dff29
commit f23e982338
No known key found for this signature in database
GPG Key ID: 1F6284E97DB46ED1

@ -267,6 +267,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi
} }
pub fn file_browser(root: PathBuf) -> Result<FilePicker, std::io::Error> { pub fn file_browser(root: PathBuf) -> Result<FilePicker, std::io::Error> {
let root = root.canonicalize()?;
let directory_content = directory_content(&root)?; let directory_content = directory_content(&root)?;
let columns = [PickerColumn::new( let columns = [PickerColumn::new(
@ -324,8 +325,15 @@ fn directory_content(path: &Path) -> Result<Vec<PathBuf>, std::io::Error> {
} }
dirs.sort(); dirs.sort();
files.sort(); files.sort();
dirs.extend(files);
Ok(dirs) let mut content = Vec::new();
if path.parent().is_some() {
log::warn!("{}", path.to_string_lossy());
content.insert(0, path.join(".."));
}
content.extend(dirs);
content.extend(files);
Ok(content)
} }
pub mod completers { pub mod completers {

Loading…
Cancel
Save