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

[BUG] 未保存的DocModel会引起文本的duplication #9

Closed situ2001 closed 2 years ago

situ2001 commented 2 years ago

当DocModel处于dirty的时候,会引起未保存文本duplicate的问题。

并且,这个问题不是我之前想的那样:不是由于ydoc没有初始化存一份在服务器引起的。。。。。。

未保存

https://user-images.githubusercontent.com/28241963/183607124-83887af6-6e23-4f38-9a85-49a5e95a29b1.mov

保存了的

https://user-images.githubusercontent.com/28241963/183607213-c4a08f89-2cad-4872-8efe-285a68d60b3a.mov

Aaaaash commented 2 years ago

这里看起来像是未保存刷新以后重复收到了插入 the hack? 的操作?

situ2001 commented 2 years ago

这里看起来像是未保存刷新以后重复收到了插入 the hack? 的操作?

直观感受起来的话,应该是会把本地保存的导致Model dirty的修改(这里是the heck?)给apply上去。

situ2001 commented 2 years ago

这里看起来像是未保存刷新以后重复收到了插入 the hack? 的操作?

直观感受起来的话,应该是会把本地保存的导致Model dirty的修改(这里是the heck?)给apply上去。

准确来说the heck?前面还有个\n

situ2001 commented 2 years ago

@Aaaaash

bug找到了...是这样的:创建的binding的时候,会与TextModel本身的content做比较的,如果不一样,就会把原来的model的content给换掉

https://github.com/situ2001/opensumi-core/blob/0a5a3f12f0220168ad824d7ce8ff8ffc7277c4e8/packages/collaboration/src/browser/textmodel-binding.ts#L237-L242

那么问题就在于,我在初始化的时候,先注册了事件

https://github.com/situ2001/opensumi-core/blob/0a5a3f12f0220168ad824d7ce8ff8ffc7277c4e8/packages/collaboration/src/browser/textmodel-binding.ts#L216

之后才去对比content。。。

https://github.com/situ2001/opensumi-core/blob/0a5a3f12f0220168ad824d7ce8ff8ffc7277c4e8/packages/collaboration/src/browser/textmodel-binding.ts#L226

PS:这个事件是这样的,会根据TextModel的changes去更新YText的内容

https://github.com/situ2001/opensumi-core/blob/0a5a3f12f0220168ad824d7ce8ff8ffc7277c4e8/packages/collaboration/src/browser/textmodel-binding.ts#L170-L183

situ2001 commented 2 years ago

而开头提到的行为,恰恰是调用到了L240的代码...

https://github.com/situ2001/opensumi-core/blob/0a5a3f12f0220168ad824d7ce8ff8ffc7277c4e8/packages/collaboration/src/browser/textmodel-binding.ts#L237-L242

situ2001 commented 2 years ago

close due to #11