Sublime Forum

ST4 sublime_text command line always opens a new window

#5

Same:
It seems not to count the initial set of cached windows opened as “existing”.
It only uses subsequent windows for newly opened files.

0 Likes

#6

Sorry for the delay. It’s not easy to me to switch from ST3 so ST4 to try this. I don’t see any suspicious log when starting.

Just wondering if there is any progress about this. This is a super blocker for me and I expect it may also be for others.

0 Likes

#7

I found the fix which worked for me and I suspect @Primokorn too.
I was running a bash command which opened 2 folders at once and then a file, and ST would never be able to find them again for new files. I believe the windows have not yet been registered as “active instances” by the time you are opening others.
So in my bash command I put a sleep 1 (second) between the 3 subl [folder/file], and it works now.

I’m not sure if it will work for @ibc, it seemed your issue was maybe more persistent.

0 Likes

#8

I’m not doing that at all. I’m not opening N folders with files at the same time. My steps to reproduce are terribly simpler than those. sublime_text command does not reuse the already launched ST4 app but opens a new instance of the ST4 app. This is not about windows, this is about ST4 app instances.

0 Likes

#9

you got this bit from settings?

// On Mac, this value is overridden in the platform specific settings.
"open_files_in_new_window": "never",

I’m not sure other than that

0 Likes

#10

Yep. I have the same problem too on Ubuntu. It is terrible because it can lead to data loss if you pick the wrong window to close and lose undo history.

0 Likes

Starting ST4 opens a new session (Windows, change from ST3)
#11

Just wondering if there is any update about this important issue which prevents (at least me) from upgrading to ST4.

0 Likes

#12

Executables on macOS are linked as either an application or command line executable. sublime_text inherently runs the application because that’s what that executable is linked to do; the subl executable is the accompanying command line tool that you should use instead.

See https://www.sublimetext.com/docs/command_line.html

0 Likes

#13

Amazing, it works. I didn’t realize ST4 comes with a SharedSupport/bin/subl. AFAIR it didn’t exist that way in ST3 and that’s why I failed to find it.

I confirm that it works correctly by using subl in command line.

0 Likes

#14

It’s existed since ST2 afaik, as that’s the only way to provide a command line tool.

0 Likes

#15

Could you please explain further? I use a Ubuntu linux distribution. Thanks.

0 Likes

#16

On Linux there’s only the one executable, this stuff only applies to macOS and Windows.

0 Likes

#17

So still no solution for Linux users?

0 Likes

#18

It should work just fine on Linux (it does for me and many others, for example). You might want to double check the command being executed by the launcher icon that starts Sublime; it might be adding extra command line parameters where none are needed.

0 Likes

#19

ST is launched through the command /opt/sublime_text/sublime_text %F
I removed %F but same problem. ST opens several windows instead of one window and several tabs.

Sublime Text Build 4113

0 Likes

#20

That sounds more like it’s restoring the previous session. Is Sublime Text already running when this happens?

0 Likes

#21

No ST is closed when it happens.
If ST is open with no tabs then all files are open in tabs.

0 Likes

#22

Just to clarify it’s specifically when opening multiple files that each file gets opened in a separate window?

0 Likes

#23

Yes.
If ST is closed (no window) and if I open 10 files (subl file1 && subl file2 && subl file3…) then 10 ST are open and each window has one tab/file.

0 Likes

#24

We’ve got a fix for this in the works.

1 Like