Hello everyone!
I occured strange problem and I don’t know yet if this is a ST (3210) bug or my own fault.
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')
).
So does anybody know why execution of command from Command Palette or from console may not trigger on_post_text_command
?
Here is a short reproducible code snippet ("Highlime paused
" is printed every time on highlime_pause 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')