Home Download Buy Blog Forum Support

on_modified passed wrong view when using clone

on_modified passed wrong view when using clone

Postby adzenith on Thu Jun 20, 2013 4:37 pm

Repro steps:
Make this plugin:
Code: Select all
import sublime, sublime_plugin

class ViewIdListener(sublime_plugin.EventListener):
   def on_modified(self, view):
      print(view.id(), sublime.active_window().active_view().id())


Open a file.
File>new view into file.
Modify the original -> same IDs.
Modify the clone -> the passed-in view's ID is different than the modified view's ID.
adzenith
 
Posts: 1204
Joined: Mon Oct 19, 2009 9:12 pm

Re: on_modified passed wrong view when using clone

Postby ashb on Sun Jun 23, 2013 8:55 am

Do you possibly want to use view.buffer_id() instead here? view.id() is just an internal ID I'm guessing.
ashb
 
Posts: 8
Joined: Thu Jun 02, 2011 9:29 pm

Re: on_modified passed wrong view when using clone

Postby adzenith on Mon Jun 24, 2013 5:24 pm

No, I'm intensely interested in the view.id. I know that they have the same buffer id because they refer to the same buffer.
In fact, I use the buffer id to work around this bug. I check if the active view is the same as the passed-in view, and if they're different I look at the buffer id. It would be nice if the passed-in view were correct in the first place though.
adzenith
 
Posts: 1204
Joined: Mon Oct 19, 2009 9:12 pm

Re: on_modified passed wrong view when using clone

Postby drifter on Mon Jun 24, 2013 7:10 pm

I don't think on_modified is any exception here. Other event callbacks seem to behave the same way. The view handle passed by any of the callbacks is always referring to the oldest view into file, regardless of which one of the open views triggered the callback. Which does seem weird, but what else is new...
drifter
 
Posts: 13
Joined: Tue Apr 23, 2013 12:17 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 11 guests