-
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
Event handlers for cloned views get called with the wrong view object #1253
Comments
Selections, however, are per-view and Related: #8 |
After some testing I came to the following conclusion: This is a bug! And I think we already have an issue for this, but I can't find it. (Please feel free to link it.) The event handlers actually do get called, but with the wrong This becomes obvious with a plugin as follows: import sublime_plugin
class SelectionChangeListener(sublime_plugin.EventListener):
def on_modified(self, view):
print("modified; view: {}, buffer: {}, primary: {}"
.format(view.id(), view.buffer_id(), view.is_primary()))
def on_selection_modified(self, view):
print("selection_modified; view: {}, buffer: {}, primary: {}"
.format(view.id(), view.buffer_id(), view.is_primary()))
print(list(view.sel())) |
Via #1504, this also applies to |
I was mistaken, acctually if you do it for 3 cloned views currently opened: lastViewId = -1
def plugin_loaded():
views = None
windows = sublime.windows()
for window in windows:
views = window.views()
for view in views:
print( "( fix_project_switch_restart_bug.py ) Calling restore_view, view id {0}".format( view.id() ) )
restore_view( view )
def restore_view( view ):
# Fix to the bug on the Sublime Text core, where all cloned views are called with the same
# view object. If we do not fix this here, it would set all the cloned views to the same
# position.
#
# #1253 Event handlers for cloned views get called with the wrong view object
# https://github.com/SublimeTextIssues/Core/issues/1253
#
global lastViewId
currentViewId = view.id()
for selection in view.sel():
print( "( fix_project_switch_restart_bug.py ) Iterating view.sel()[i].begin() {0}".format( selection ) )
if( lastViewId != currentViewId ):
# print( "( fix_project_switch_restart_bug.py ) Setting show_at_center to view id {0}".format( view.id() ) )
view.show_at_center( view.sel()[0].begin() )
lastViewId = currentViewId You will get:
|
The bug still exists in 3140. Any progress? It causes all packages which use this function to fail on cloned views. Even though it does not cause crashes, it should be fixed soon. No python driven auto-completion or anything like that works for cloned views. |
Related or maybe duplicate of #289 |
I knew we had one for this (see my first comment). Closing as duplicate. |
Submitting a feature or enhancement request:
1. Explain briefly what the enhancement is and why you think it would be useful.
The enhancement is to call the events 'on_selection' and 'on_modified' from cloned views.
It is useful because I work with big files as long as 7000 lines, hence I need to operate from multiple cloned views which use plugins that relies on the 'on_selection' and 'on_modified' events being called from cloned views
2. Provide any other necessary or useful information regarding your issue, such as (code) examples or related links.
This issue is related on the 'facelessuser/BracketHighlighter#356'. That plugin relies on the 'on_selection' and 'on_modified' events to work properly, however they are not being called from cloned views.
Environment
The text was updated successfully, but these errors were encountered: