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

Expand ~ when parsing file paths in :open #5329

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion helix-term/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ impl Args {

/// Parse arg into [`PathBuf`] and position.
pub(crate) fn parse_file(s: &str) -> (PathBuf, Position) {
let def = || (PathBuf::from(s), Position::default());
let def = || {
(
helix_core::path::expand_tilde(Path::new(s)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to call this from open in helix-term/src/commands/typed.rs. We don't need to do this for files passed in the argv since the shell will do the tilde expansion and there's a small bug here where :open fails if you give it a directory that has a tilde and a row or row/col position (though that isn't a use-case that makes sense)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, makes sense 👍

Position::default(),
)
};
if Path::new(s).exists() {
return def();
}
Expand Down