Sublime Forum

saveAll on_pre_close_window

#1

I would like Sublime Text to ask about unsaved changes when the user closes a window and there are other windows open. The application preserves unsaved changes when the last window is closed. Even though I know the app does not preserve unsaved changes when a non-last window is closed, I have lost unsaved changed multiple times because I forgot that there was another window open.

I’ve discovered a way to make this happen, but I think the behavior should be part of the base code, not something users need to set up themselves. My method is:

  1. Install the Hooks package.

  2. Add the following to the sublime-settings file:

     "on_pre_close_window": [
       {
         "command": "saveAll",
         "scope": "window"
       }
     ]
    

I think this would be an easy change to implement.
Thanks for considering my request.

0 Likes

#2

ST always prompts to save unsaved changes if those changes are about to be thrown away. The only times it doesn’t prompt is if the unsaved changes are saved in the session (when the app is quit) and when the unsaved changes are saved in a workspace file (when you’re using a project).

0 Likes

#3

I prefer that ST prompts me to save unsaved changes every time, either in individual files or projects. I have the options below in my settings. My understanding is that the last option is undocumented.

"hot_exit": "disabled",
"hot_exit_projects": false,
"remember_open_files": true,
0 Likes