Skip to content

Commit

Permalink
Add parent folder to file browser
Browse files Browse the repository at this point in the history
  • Loading branch information
drybalka committed Oct 3, 2024
1 parent 29eb26b commit 810700c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions helix-term/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
let root = root.canonicalize()?;
let directory_content = directory_content(&root)?;

let columns = [PickerColumn::new(
Expand Down Expand Up @@ -324,8 +325,15 @@ fn directory_content(path: &Path) -> Result<Vec<PathBuf>, 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 {
Expand Down

0 comments on commit 810700c

Please sign in to comment.