Cursor-Plugin check for isChangeOrigin is always undefined
jamesopti opened this issue · comments
Describe the bug
The cursor-plugin checks for isChangeOrigin
by looking at the sync plugin's state (ySyncPluginKey.getState(newState)
)
I believe this should actually be looking at the ysync transaction meta for this field (tr.getMeta(ySyncPluginKey)
)
In my testing, the former is always undefined, where the latter is true
for cases where the doc is changed by another browser instance.
Creating new decorations still works but I assume it is less performant.
To Reproduce
Steps to reproduce the behavior:
- Add a console.log to
yCursorPlugin > state > apply
with the value ofySyncPluginKey.getState(newState)
- Open a document in 2 different browser windows and type in one of them
- Observe that the value is always
undefined
Expected behavior
The isChangeOrigin
check properly reflects if the doc was changed by another user.
Additional context
Discovered this while trying to mimic the cursor plugin behavior in our own plugin.
Closing this as the issue was the order of plugins.
My feature plugin was running before the ySync plugin, preventing it from reading the updated state of that plugin before it ran.