Sublime Forum

'Close window' on the last window is currently broken

#1

Closing a window (either with Shift+Ctrl+W or with the window manager close button) usually entails the following process:

  1. Ask for confirmation (Save changes to X before closing?) for any unsaved tabs.
  2. If Cancel is pressed in any of the confirmation dialogs, abort the window close operation.
  3. Otherwise, close the window for good.

But if you perform Close window on the last (or only) application window, the behavior becomes that of File / Quit, or Ctrl+Q, at least on Linux:

  1. Quit the application, saving all the open files and windows for next time.

This is a bug, because it renders subl (and other methods of launching ST) dependent on whether there are other windows currently open in other workspaces: if there are other windows open somewhere else, subl -n will open a new blank window; otherwise, it will also open the last window you worked on.

I believe the Close Window and Quit Program should be separate commands.

Is there a plugin that makes it possible to invoke the Close Window function even when there are no other windows visible? I tried https://github.com/mreq/sublime-better-close-window but it does not seem to be working.

0 Likes

#2

have you considered setting hot_exit to false in your preferences? The default is true:

// Exiting the application with hot_exit enabled will cause it to close
// immediately without prompting. Unsaved modifications and open files will
// be preserved and restored when next starting.
//
// Closing a window with an associated project will also close the window
// without prompting, preserving unsaved changes in the workspace file
// alongside the project.
"hot_exit": true,
1 Like

#3

You were probably using unnamed (unsaved) projects in the other windows, which cannot have their state preserved as the don’t have a location to save it to.

1 Like

#4

@kingkeith If I set hot_exit to false, ST will not preserve open windows, open files, and unsaved work if my computer crashes. That’s an important feature that I don’t want to lose.

But at the same time, when I actually want to close a window and it happens to be the last, there is no way to do it.

@FichteFoll Yes, I have never used the saved project feature. I have so many different project and folder combinations that I don’t have time to create a sublime-project file for each. I just use subl -n and subl -a on the folders that I need to open.

But I don’t think this has much to do with the Close Window function being broken when closing the last window.

0 Likes

#5

are you sure? have you observed that behavior? I was thinking maybe ST still saves the session information periodically, just discards it when the user closes the application.

0 Likes

#6

I tested hot_exit and I can’t seem to be able to figure out what it does.

In any case, the last window bug is still there even with "hot_exit": false

I just closed the last window, re-launched ST with subl /some/folder from the terminal, and I got two windows: the new one and the last one.

0 Likes

#7

As I remember, you have to quit ST twice to apply "hot_exit": false.

1 Like