From f23e98233820c566efe2226d7b8b8986867fa81f Mon Sep 17 00:00:00 2001 From: Denys Rybalka Date: Sat, 10 Aug 2024 11:26:56 +0200 Subject: [PATCH] Add parent folder to file browser --- helix-term/src/ui/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index ae06013b5..62c9fb912 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -267,6 +267,7 @@ pub fn file_picker(root: PathBuf, config: &helix_view::editor::Config) -> FilePi } pub fn file_browser(root: PathBuf) -> Result { + let root = root.canonicalize()?; let directory_content = directory_content(&root)?; let columns = [PickerColumn::new( @@ -324,8 +325,15 @@ fn directory_content(path: &Path) -> Result, std::io::Error> { } dirs.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 {