Sublime Forum

ST opens an extra window when opening document

#1

Hello,

I have ST build 4113 on Mac OS 11.5.2. When I open a new document by clicking on it, or a project with subl ., ST always opens a new blank editor window together with it. How do I fix this so only the relevant project / doc is gets opened?

Thanks.

0 Likes

#2

Is ST already open when you do this? Normally ST will restore previously open windows if you quit the application; see the "hot_exit" setting.

0 Likes

#3

Nope, when the app is already open it will only open the doc thatā€™s clicked or the project thatā€™s opened. When the app isnā€™t open it will open a blank new window and bring it into foreground / focus (with the above in the background).

Also, it does not restore anything from the previous session.

0 Likes

#4

Sorry Iā€™m not following. Can you specify the exact behaviour youā€™re seeing and what you expect to happen instead?

0 Likes

#5

When I open a doc D or a project P, ST also opens a blank (empty) new window W ALONGSIDE with D or P. So instead of just having one open window (D or P), I end up with TWO open windows: D or P and W.

What I expect to happen instead: for ST to open D or P without also opening W.

Hope that makes sense.

0 Likes

#6

Is the Sublime Text application running already when this happens? Note that an application may be running even without any windows open.

0 Likes

#7

No, this happens only when the ST application is NOT running. When itā€™s already running only the clicked doc (or a project opened with subl . ) gets opened.

0 Likes

#8

What executable is subl linked to?

0 Likes

#9

Not sure about that. When I was installing ST on this machine, I used this (am using bash):

echo 'export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"' >> ~/.bash_profile

(as per these instructions: https://www.sublimetext.com/docs/command_line.html#mac)

The current output of echo $PATH is this:

/Users/me/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin
0 Likes

#10

You can find out by running ls -al $(which subl).

0 Likes

#11

Thanx! The output is:

May 15  2020 /usr/local/bin/subl -> /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl
0 Likes

#12

Does the "create_window_at_startup" change anything?

0 Likes

#13

Iā€™ve set "create_window_at_startup": false, and now the subl . command only opens the current project directory. However when I click open a Markdown file on my Desktop it still opens a new window alongside with the file. In both cases, I exit the ST application beforehand.

0 Likes

#14

I have the same issue on Windows 10 and 11. When opening Sublime only everything is fine. If I open a document with sublime it opens additional empty windows in the background (in most cases 2 extra windows).

Update:
No behaviour change with
ā€œcreate_window_at_startupā€: false

0 Likes

#15

Iā€™m noticing similar behavior on both WIndows 10/11 and Linux. If I run subl ., I get two windows; however, if I open a single document, then I get only one window.
Adding "create_window_at_startup": false to my settings makes no difference.

I began noticing this behavior after an update within the last couple of weeks. Unfortunately, I canā€™t be any more specific than that. Currently, Iā€™m on build 4116 on both Windows & Linux.

0 Likes

#17

Weā€™ve got a fix for this in the works.

0 Likes

#18

Just to make an update, the latest build (4121) partially solves this issue. The extra window doesnā€™t pop up when a project is opened with subl . ā€” but DOES pop up when a file is clicked open or opened with CMD+O (on Mac OS).

0 Likes

#19

Iā€™m not sure if this is the bug described here or a new bug:

This is on a MacBook Pro/Intel with Catalina.

Since Build 4121 when I open a file by double-click in Finder, Sublime Text opens a new window/workspace with the file clicked, so far so good.

There is only this window in this workspace, the window with the opened file.

When I click on the red close icon top left, the window/workspace disappears.

But when I close the window with Command-W or click on the ā€œxā€ on the file tab, then the file closes, but a new ā€œUntitledā€ file shows, which wasnā€™t there before.

I have to close this ā€œUntitledā€ file again to get rid of the window/workspace.

BTW Sublime Text was running before, it is always running on my machine :wink:

0 Likes

#20

Iā€™m unable to reproduce that. Opening a file using cmd+o simply opens the file in the current window, no additional windows are opened. Does it happen in safe mode?

0 Likes

#21

I can confirm the behavior seems to match what @farrol statesā€”note that it doesnā€™t seem to create two windows when you open from Finder (Cmd+O or double-click), but it has like a ā€˜ghost windowā€™ behind the active tab (named untitled) that you end up having to close after you close the document you just opened.

This has been bugging the heck out of me lately, enough to come here and post this animated gif of exactly the issue.

My current preferences file is here: https://github.com/geerlingguy/mac-dev-playbook/blob/master/files/sublime/Preferences.sublime-settings

I have both:

  "close_windows_when_empty": true,
  "create_window_at_startup": false,

And Iā€™m running build 4121 on macOS 11.6.

Hereā€™s the gif:

In the first example, I double-click to open the file, then click the close icon on the tab. An untitled window is left in place that I also have to close.

In the second example, I double-click to open the file, then press Command-W to close the file. An untitled window is left in place that I also have to close.

0 Likes