Open deathaxe opened 7 years ago
As the unofficial documentation states
If Sublime Text isn’t running already, only
ApplicationCommands
will work when invoked from the command line. If Sublime Text is already running,WindowCommands
will work as well when invoked from the command line.
I'm going to mark this as an enhancement and not a bug. Basically, it just doesn't wait for all packages to load before executing the command line commands.
I know what documantation says, but as subl.exe provides the feature to run any command, it should work reliable for all commands provided by any package, no matter of name or number of installed packages. IMO it is not an issue of ApplicationCommand or WindowCommand, but a kind of race condition. Try to run any kind of command of the Default.sublime-package and you'll see it works well. The issue simply is, that a command can be be called at a point of time, when its providing package is not yet loaded. This makes the whole --command argument a kind of useless. From this point of view it is a bug.
Oddly, it's both a bug and an enhancement since the behavior is definitely not as documented (or "inconsistent").
I can't get any command to execute when ST isn't running, not even an ApplicationCommand. Wondering if I'm doing something wrong or my expectations are wrong. The unofficial documentation states:
If Sublime Text isn’t running already, only ApplicationCommands will work when invoked from the command line. If Sublime Text is already running, WindowCommands will work as well when invoked from the command line.
What I've tried:
import sublime_plugin
class BatmanCommand(sublime_plugin.ApplicationCommand):
def run(self):
print('batman')
$ subl --command batman
I get nothing. The command executes fine if ST is already opened, but if starting cold then the command never runs. Is this a bug. A known bug? Or am I doing something wrong?
ST not waiting for plugins to be loaded before trying to run the command specified via command line might still be the deciding factor here even for ApplicationCommands. Until this is fixed or properly documented, the docs should most likely be updated to discourage from using this functionality unless ST is already running.
Summary
My main intention is to set up Sublime Text as merge tool with GitExtensions as desciped here: http://www.sublimerge.com/sm3/docs/vcs-integration.html#command-templates-merge-tool-3-way
I added the following line to GitExtensions configuration:
subl.exe -n --wait %theirs %base %mine %merged --command "sublimerge_diff_views"
I also tried to create a "hello world" command in a hello_world.py which should be executed by subl.exe -n --wait --command "hello_world". without success. It looks like a timing issue, because if the package name begins with something like "A", it works. From my point of view sublime text does not wait for all packages to be loaded before trying to execute the command provided by the command line argument.
Expected behavior
Sublime Text starts and runs the
sublimerge_diff_views
command.Actual behavior
%theirs
,%base
and%merged
without executing thesublimerge_diff_views
command. If Sublime Text is already running,sublimerge_diff_views
command is executed as expected.Steps to reproduce
subl.exe -n --wait theirs.txt base.txt mine.txt merged.txt --command "sublimerge_diff_views"
or just create a simple command in a package named Zzz.sublime-package, which is loaded very late and try to run it with subl.exe -n --wait --command ...
Environment