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

When :w non-existing directory, suggest :w! to create it #5229

Closed
matklad opened this issue Dec 20, 2022 · 0 comments · Fixed by #7014
Closed

When :w non-existing directory, suggest :w! to create it #5229

matklad opened this issue Dec 20, 2022 · 0 comments · Fixed by #7014
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements

Comments

@matklad
Copy link
Contributor

matklad commented Dec 20, 2022

If I do hx does-not-exist-yet/file.rs and then :w, I get the error message about directory not existing. It would help if the error message mentioned :w! as a way to create a directory.

Perhaps we can just change

bail!("can't save file, parent directory does not exist");

to be

"can't save file, parent directory does not exist (use :w! to create it)"

I am somewhat hesitant to do just that, as that is a somewhat low-level function and it's not necssary called in an interactive context.

I think the proper way to do this is to wrap some magical type like ErrorWithInterractiveHint into anyhow, and then downcast it at the call-site, but that seems like a lot of machinery which I am reluctant to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants