sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
803 stars 39 forks source link

Automatically create folder structure when saving file #1888

Open leonklingele opened 7 years ago

leonklingele commented 7 years ago

When trying to save a file in a non-existing directory you get an error message:

Unable to save /develop/path/to/file.txt
Error: No such file or directory

This is because the to folder / its parent / its parent's parent / .. doesn't exist. ~Sublime however still creates the folder structure and saves the file. I'm asking to not show the error message at all.~ I'm asking to automatically (re)create the missing folders.

Steps to reproduce

$ cd $(mktemp -d)
$ mkdir -p path/to
$ touch $_/file.txt
$ subl .

Now open file.txt inside the Sublime window, add some text and save.

$ rm -r path/to

Switch back to the Sublime window and try to save file.txt again and receive the error message from above.

Expected result

Sublime should (re)create the folder structure and should not show an error message as it serves no purpose imo.

Environment

EDIT:

OdatNurd commented 7 years ago

Are you saying that if I follow your steps above, when I press save I should get an error message, but Sublime has put back the folder that you removed and saved the file anyway?

If so I can't replicate that at all; I get an error message, the file is still not on disk, and the file buffer is still unsaved as I would expect it to be.

I suspect you may have a package installed that tries to create missing folder structures on save.

leonklingele commented 7 years ago

You're right. Reproducing with a clean installation does indeed not recreate the folder structure. I'm sorry for this.

I have adjusted this issue accordingly: There should be no error message and the missing folders should be created by Sublime.