-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on_selection_modified
should be called only once and with the view where the selection was modified
#2990
Comments
Each cloned view receives the It's up to a plugin to handle or ignore the event for all or the active view only. class MyListener(sublime_plugin.EventListener):
def on_selection_modified(self, view):
if not view.window():
return
if view == view.window().active_view():
print(f"on_selection_modified called for active View {view.id()} : {view.file_name()}.")
else:
print(f"on_selection_modified called for inactive View {view.id()} : {view.file_name()}.") |
I doubt this is an excellent solution to the "cloned view" problem. This puts the responsibility in the hands of plugin developers. It's a "gotcha" that's easily overlooked. On the other hand, it's certainly a solution that we can work with. |
Let’s reopen so I can take another look |
ST can't know whether a plugin wants to be informed about the active view or all views, so this is propably the most flexible solution. |
With regards to #289 it would mean to propably implement a special behavior for How about adding a |
But each view maintains its own selection whether cloned or not. So calling |
ST 4070 still fires the event for all clones. |
This branch hasn't been merged yet, I'll update the milestone |
This should be fixed in 4072 |
IMHO, this issue is only partly fixed. It works, if the caret is moved in one of the views without modification to the content. But if the content changes, the It might be logical if the caret of the inactive was moved by the modification, but that's not the case. Please see how the caret of the primary (left) view is moved to the beginning of the file and how the |
It is probably that we aren’t checking all of the selections in the inactive view to see if at least one is after the modification. |
Sub-issue from: Multiple event hooks don't work with clones #289
Actual behavior
If I have 10 clones into a view, I get
on_selection_modified
called 10 times, and each time it always have the primary view as the view parameter.Expected behavior
If I have 10 clones into a view, the
on_selection_modified
event should be called only 1 time, with the view on which the selection was modified (not the primary view).Environment
10 build 15063 x64
1920x1080
1.0
3207
Related threads
on_selection_modified
) called beforeplugin_loaded
#1508The text was updated successfully, but these errors were encountered: