Sublime Forum

ST4 sublime_text command line always opens a new window

#1

Having Sublime Text already running.

  • In ST3 if I run subl FILE it opens a new tab in current Sublime Text window.

  • In ST4 if I run sublime_text FILE it always open a new Sublime Text process (a separate ST icon in the macOS Dock to be clear). I’ve tried all command line options, no one changes this behavior.

I open like 40 files via command line every day. I hope this is a regression and not new expected behavior.

0 Likes

#2

I’d go further and say that no sublime_text command line option works at all. However note that in my topic above I’m not even trying to use any of them (it was not needed in ST3 which behaved as expected).

0 Likes

#3

That is definitely not intended behaviour no; it doesn’t happen on Linux or Windows for example.

Does the Sublime console display any messages near the top when it’s starting up that might shed some light? It sounds like it’s not able to effectively determine that there’s a copy already running.

Additionally, the Golang Build package is known to cause issues on some systems: https://github.com/sublimehq/sublime_text/issues/4098

0 Likes

#4

Hello,
Same issue here since I upgraded to ST4 - stable channel build 4107 - Ubuntu/Debian Linux distribution
In my settings the option is disabled:
“open_files_in_new_window”: “never”,

EDIT: it seems that it only happens if no ST window is already opened. Can someone confirm?

0 Likes

#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