Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Open file picker by default when the specified path is a directory #51

Closed
vv9k opened this issue Jun 2, 2021 · 7 comments
Closed
Labels
E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@vv9k
Copy link
Contributor

vv9k commented Jun 2, 2021

I would like to see the contents of a directory when opening hx with a path to directory like:

hx /tmp

Shows me file picker with the contents of /tmp.

I would like to give a try at implementing this.

@archseer archseer added the E-easy Call for participation: Experience needed to fix: Easy / not much label Jun 2, 2021
@archseer
Copy link
Member

archseer commented Jun 2, 2021

I like this idea, but I wonder what the behavior should be if several files/folders are listed, i.e. hx /tmp log.txt

@vv9k
Copy link
Contributor Author

vv9k commented Jun 2, 2021

That's also what I currently stumbled upon. I'm wondering how to handle this with what there is available now.

@archseer
Copy link
Member

archseer commented Jun 2, 2021

You should be able to reuse the file picker code here:

let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
let picker = ui::file_picker(root);
cx.push_layer(Box::new(picker));

You would need to construct it if necessary, and compositor.push it right after the editor here:

if !args.files.is_empty() {
for file in args.files {
editor.open(file, Action::VerticalSplit)?;
}
} else {
editor.new_file(Action::VerticalSplit);
}
compositor.push(Box::new(ui::EditorView::new()));

@vv9k
Copy link
Contributor Author

vv9k commented Jun 2, 2021

Already got that figured out, I'm wondering what to do with the extra arguments aftrer initial directory path like hx /tmp some_file - what to do about some_file there. Perhaps all extra files should be opened as splits?

@vv9k
Copy link
Contributor Author

vv9k commented Jun 2, 2021

And also what to do when there is more than one directory like:

hx /tmp /home some_file

@vv9k
Copy link
Contributor Author

vv9k commented Jun 2, 2021

I added initial changes in #59

@archseer
Copy link
Member

archseer commented Jun 4, 2021

Closed by #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

No branches or pull requests

2 participants