Sublime Forum

on_modified passed wrong view when using clone

#1

Repro steps:
Make this plugin:

[code]import sublime, sublime_plugin

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

[/code]
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.

0 Likes

#2

Do you possibly want to use view.buffer_id() instead here? view.id() is just an internal ID I’m guessing.

0 Likes

#3

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.

0 Likes

#4

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…

0 Likes