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

Add :write! to create nonexistent subdirectories #1839

Merged
merged 3 commits into from
Apr 12, 2022

Conversation

Omnikar
Copy link
Contributor

@Omnikar Omnikar commented Mar 18, 2022

Closes #1834.

@Omnikar Omnikar changed the title Make :write create nonexistant subdirectories Make :write create nonexistent subdirectories Mar 18, 2022
Prompting as to whether this should take place remains a TODO.
Comment on lines 472 to 475
// TODO: display a prompt asking the user if the directories should be created
if !parent.exists() {
bail!("can't save file, parent directory does not exist");
std::fs::DirBuilder::new().recursive(true).create(parent)?;
}
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 we should at least show a status message that new directories were created (or even better a prompt like the TODO says).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would we display a status message or a prompt from this function?

@archseer
Copy link
Member

Should this be a part of :w! but not :w? That way accidentally typoing on :w won't create a whole directory structure.

@Omnikar
Copy link
Contributor Author

Omnikar commented Mar 31, 2022

Oh, that seems like a good idea.

@sudormrfbin
Copy link
Member

Should this be a part of :w! but not :w? That way accidentally typoing on :w won't create a whole directory structure.

That seems better, we could also show a message on a failing :w to use :w! to create intermediate directories.

@dead10ck
Copy link
Member

dead10ck commented Apr 2, 2022

Should this be a part of :w! but not :w? That way accidentally typoing on :w won't create a whole directory structure.

That's a great idea. Best of both worlds.

@Omnikar
Copy link
Contributor Author

Omnikar commented Apr 3, 2022

Should this be a part of :w! but not :w? That way accidentally typoing on :w won't create a whole directory structure.

What do we want to do about the functionality of :wq!? Should it combine :w! and :q!, or should it just remain as combining :w and :q!?

@archseer
Copy link
Member

archseer commented Apr 5, 2022

Should it combine :w! and :q!

I think this ^

! means "I just want to get this out of my way, no errors, just close it"

@Omnikar Omnikar changed the title Make :write create nonexistent subdirectories Add :write! to create nonexistent subdirectories Apr 6, 2022
@Omnikar Omnikar requested a review from sudormrfbin April 8, 2022 01:56
@archseer archseer merged commit 660e0e4 into helix-editor:master Apr 12, 2022
@Omnikar Omnikar deleted the write-create-dirs branch April 15, 2022 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make :write create directories if they don't already exist
4 participants