situ2001 / opensumi-core

🚀 A framework helps you quickly build Cloud or Desktop IDE products.
https://opensumi.com/zh
MIT License
0 stars 0 forks source link

Notes 📝 #7

Open situ2001 opened 1 year ago

situ2001 commented 1 year ago

发现有时候,某uri的TextModel会绑不上该uri对应的最新的YText。花了一下午阅读代码,以及逛了yjs forum,发现如下几点

要把yDoc在服务端给初始化好且保存好(需要历史信息解决冲突) 参考: https://discuss.yjs.dev/t/whats-the-correct-way-to-set-default-content-for-y-prosemirror/1129 https://discuss.yjs.dev/t/idempotently-setting-the-initial-document-content-with-webrtc/509 https://discuss.yjs.dev/t/appropriate-way-to-load-initial-data-fallback-to-current-yjs-doc-data/1189 https://discuss.yjs.dev/t/how-to-fetch-init-data-in-server-side/158

其实发现bug的时候慌了一下,以为没有做这一点,但实际上我是做了的:YText初始化工作交给服务器来做,前端接收yMap的event。但有时候在频繁地删除文件,移动文件的时候,就有可能会出现TextModel duplicate了内容或者显示了之前的内容。

yMap是在yDoc同步后趋于一个确定的状态的,这是CRDT的特性 参考自:https://discuss.yjs.dev/t/locking-using-yjs/801

这里应当转换思路,本地的TextModel不变,变化的是CRDT中,YMap的YText

situ2001 commented 1 year ago

以及可以考虑subDocument:https://discuss.yjs.dev/t/how-to-sync-thousands-of-documents-and-have-local-persistent-store/377

不过比较麻烦,现在应该是要先解决上面的异步事件的顺序问题

situ2001 commented 1 year ago

yMap是在yDoc同步后趋于一个确定的状态的,这是CRDT的特性 参考自:https://discuss.yjs.dev/t/locking-using-yjs/801

这里列出其中的一个case

image
situ2001 commented 1 year ago

yMap是在yDoc同步后趋于一个确定的状态的,这是CRDT的特性 参考自:https://discuss.yjs.dev/t/locking-using-yjs/801

这里列出其中的一个case

Check #10