Sublime Forum

ViewEventListener.on_text_command() is not called on a view obtained with the clone_file command?

#1

I wrote the following plugin

import sublime
import sublime_plugin

class ExampleListener(sublime_plugin.EventListener):

    def on_text_command(self, view, command_name, args):
        print("window_on_text_command")

    def on_modified(self, view):
        print("window_on_modified")

class ExampleViewListener(sublime_plugin.ViewEventListener):

    def on_text_command(self, command_name, args):
        print("view_on_text_command")

    def on_modified(self):
        print("view_on_modified")

moving the cursor yields the following output

view_on_text_command
window_on_text_command

typing “a” yields the following output

window_on_modified
view_on_modified

but, If the tab is a duplicate of the clone_file command, the output will look like this.

moving the cursor:

window_on_text_command

typing “a”:

window_on_modified
view_on_modified
window_on_modified <- (I think this is because there are two tabs duplicated)

Is it a specification that on_text_command is not called when tabbed by clone_file command? Or is it a bug?

0 Likes

#2

http://www.sublimetext.com/docs/api_reference.html#sublime_plugin.ViewEventListener

Control the behaviour with

applies_to_primary_view_only

0 Likes

#3

I see! Thank you :heavy_heart_exclamation:

0 Likes