-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Show file picker when opening a directory #59
Conversation
So this is what i initially came up with. It will open all files as splits, the last path that is a directory will end up as file pickers root. All other directories will be silently ignored. Here is an example of invoking:
Upon user selection from file picker, the file will end up in the split that is empty as it is focused. |
I don't think this is a good idea. It's quite weird to take in both directory and files, and what if users send in two directories? Show two file picker? I think it is hard to estimate the behavior, a better option would be to give an error saying users cannot send in directory and file together. |
So basically only allow either a single directory or single/multiple files? |
That's what I think, not sure if others have this in mind as well. |
I do like this behaviour better so I updated the code to reflect that. |
I think iterating over the files at least once to detect their type first would be ideal, instead of pushing contexts only to error later once another directory is found. Some pseudo code let file_count = 0;
let dir_count = 0;
for file in files {
if (file.is_dir()) {
dir_count += 1;
} else {
file_count += 1;
}
}
if (dir_count > 1) {
// raise here, we can't handle more than one directory
// we also don't waste clock cycles on opening buffers that will be discarded because of the panic
}
if (file_count > 0) {
// open the buffers
}
if (dir_count > 0) {
// open the file picker also
}
if (file_count == 0 and dir_count == 0) {
// open default buffer instead
} You could also replace the counters with a vector instead to collect the files that should be opened in buffers before finally opening the file picker for the directory if needed Just my 2-cents |
@IceDragon200 I don't agree. We can just stop once we hit a weird case. So if the first argument is file the rest is file, once a directory is found error. But directory should only be able to open for one directory, so if there are more arguments for directory, error. |
Thanks! 🎉 |
No description provided.