You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like sublime_plugin.EventListener does not see commands executed via Command Palette and from ST console. There is no problem with command calls from main menu / hotkeys though.
I’m developing a plugin that works in background and must be stopped when appropriate command is given.
So I’m using sublime_plugin.EventListener.on_post_text_command to change environment when expected command was executed.
And it works normally when I call the command from the main menu / by the hot keys.
But on_post_text_command never triggers when I run the command from Command Palette (which is a comfort way to control the plugin) or from console (like sublime.run_command('highlime_pause')).
Tested on operating systems: Windows 10 / Arch Linux Sublime Text builds: 3210, 4074
I tried not only on_post_text_command but also on_text_command - and together with issues #2234 and #2400 it looks like the problem is actual for all sublime_plugin.EventListener.on_*_command listeners.
Summary: Now it looks impossible to catch command call events from Command Palette or ST console so it may cause improper work of plugins (when the command is executed but the listener did not trigger)
Here is a short code snippet that can be used to reproduce a bug ("Highlime paused" is printed every time on highlime_pause command call but “GOTCHA!” won’t be printed if command was called from Palette/console):
import sublime
import sublime_plugin
PLUGIN_ACTIVATED = False
# Listener to stop the plugin when requested:
class HighlimePauseCommandListener(sublime_plugin.EventListener):
def on_post_text_command(self, view, command_name, args):
if command_name == 'highlime_pause':
print('GOTCHA!')
global PLUGIN_ACTIVATED
PLUGIN_ACTIVATED = False
# Command to signalize that we want to stop the plugin:
class HighlimePauseCommand(sublime_plugin.TextCommand):
def run(self, edit):
print('Highlime paused')
Hello!
It looks like
sublime_plugin.EventListener
does not see commands executed via Command Palette and from ST console. There is no problem with command calls from main menu / hotkeys though.I’m developing a plugin that works in background and must be stopped when appropriate command is given.
So I’m using
sublime_plugin.EventListener.on_post_text_command
to change environment when expected command was executed.And it works normally when I call the command from the main menu / by the hot keys.
But
on_post_text_command
never triggers when I run the command from Command Palette (which is a comfort way to control the plugin) or from console (likesublime.run_command('highlime_pause')
).Tested on operating systems: Windows 10 / Arch Linux
Sublime Text builds: 3210, 4074
I tried not only
on_post_text_command
but alsoon_text_command
- and together with issues #2234 and #2400 it looks like the problem is actual for allsublime_plugin.EventListener.on_*_command
listeners.Summary: Now it looks impossible to catch command call events from Command Palette or ST console so it may cause improper work of plugins (when the command is executed but the listener did not trigger)
Here is a short code snippet that can be used to reproduce a bug ("
Highlime paused
" is printed every time onhighlime_pause
command call but “GOTCHA!
” won’t be printed if command was called from Palette/console):Forum topic where the history started: https://forum.sublimetext.com/t/sublime-plugin-eventlistener-works-differently-on-command-call-from-menu-hotkey-and-command-palette-console/52007
The text was updated successfully, but these errors were encountered: