Issues with passing file paths on launch
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
This is related to 9edd81c and #10843, it is not really a bug report.
There's 3 options when passing a path:
- pass a folder
- pass a file
- pass a file with row/col/both
Before 9edd81c, at least on windows, none of these seemed to work, with the commit both option 1 and 2 work fine (need confirmation on whether these work on !windows though). However, as it stands in the code right now, 3 does not make any sense.
The problem starts in this match. This initially tries to create a Path out of the input. In cases 1 and 2, this works perfectly, we get a full path, convert it to a string and return.
The problem is that if we are instead in case 3, this will error and we will instead go to the else block, even if the input argument is technically valid. Eventually through zed.main, we arrive in OpenRequest::parse in PathLikeWithPosition::parse_str. As someone with a solid 2 hours of experience in this codebase that has no clue about what is going on this feels rather redundant and error-prone. Not to mention it currently does not work as expected since case 3 type files can never be passed here since they are treated as errors in the parse_url_arg function so it seems to do nothing.
After messing around with this locally for a bit, I think it would make more sense for parse_url_arg to return some new type that would look something like this:
enum InputPath {
PathLikeWithPosition(PathLikeWithPosition),
Url(String) // or maybe some other more concrete type here
}
I found Strings to end up annoying to deal with for this specific case as I had to go back and forth with parsing them and making sure they are the correct type, this should simplify things (and make the parsing a lot simpler.
Not sure if this makes sense or if it is the best way to deal with the problem, curious what other people think.
Environment
Zed: v0.135.0 (Zed Dev f99b24accad60a825448e116455dc4f24d0ee485) OS: Windows 10.0.22631 Memory: 31.9 GiB Architecture: x86_64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.
No response