Sublime Forum

Why is there a "Close everything without warning or saving unsaved files" command?

#1

This seems broken—if Sublime warns you when you close a file without saving, why does it allow you to close MULTIPLE files without saving? Is there any way to disable this behavior? Why is it the default?

0 Likes

#2

If you have "hot_exit": true set (the default), ST will save your current unsaved buffers and restore them on the next start or, if are using a project and only closed that, when you re-open the project/workspace.

If you don’t have hot_exit enabled, it should prompt you for unsaved changes, although I never tested that as I have hot_exit enabled.

0 Likes

#3

What if you’re not in a project or workspace?

0 Likes

#4

If you close a window with an anonymous project, ST will warn about unsaved changes regardless of hot_exit. If you close the entire application (with ctrl-q), ST will only ask if hot_exit is true.

1 Like

#5

When hot_exit is turned on, you get the following behaviour:

  1. If you quit Sublime, the state of every window is persisted into the session file and restored when you restart.
  2. If you close a window that’s associated with a project, then the state of that project it persisted into it’s own sublime-workspace file and restored the next time you open that project/workspace
  3. If you close a window that’s not associated with a project, you get prompted to save every file that has unsaved changes, one after the other, and at any point you can choose Cancel to stop the window close from happening.

Here “persisted” means that the layout of the window, the list of open files, the content of open files (even if it’s not saved), the cursor locations, the selection state, etc all get saved and put back to exactly what they were before on load; as if you never quit.

On the other hand, with hot_exit turned off:

  1. If you quit Sublime, you get prompted to save every unsaved file in every window one after the other (as in #3 above), and at any point selecting Cancel blocks the Quit from happening. Nothing is persisted, so when you restart Sublime you get a single window back (with no files open).
  2. If you close any window, whether it contains an explicit project or not, you get prompted to save any unsaved files. Picking Cancel blocks the close. Nothing is persisted; if you close a project this way, when you re-open it the layout of the window is the same as it was before, but no files are open.

Here “not persisted” means that except for saving the layout of the window and other misc details (like whether the side bar was open or not), no file content is saved at all, which includes the fact that any files were open at all.

It’s up to the individual user whether or not the hot_exit scenario is desirable or not. Certainly with it turned on you can close windows or quit Sublime with impunity (more or less) without worrying about losing any data or any state, whereas with it turned off every time you start Sublime you get a complete fresh slate.

3 Likes