-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: reset yTextMap when file updated by system #2260
Conversation
@@ -266,6 +281,16 @@ export class CollaborationService extends WithEventBus implements ICollaboration | |||
} | |||
}; | |||
|
|||
private handleFileChange(e: FileChangeEvent) { | |||
e.forEach((change) => { | |||
// 只有从文件系统更新,并且窗口未打开情况,才重置 yTextMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果窗口已打开呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
窗口打开时候,文件更新会同步,相应的 map 内容也会更新
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
曾经考虑过 简单地 进行监听文件系统更新,但以失败告终,供参考:situ2001#19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 PR 主要是考虑非协同场景的 BUG,目前单用户加载了协同模块会出现通过 git 等操作修改代码后再打开文件,内容被恢复了。
协同场景的文件变更同步还需要修改 FileWatcher,现在文件监听在协作场景还有 BUG,需要单独开一个 Issue 解决了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一个粗略的想法:把 Model <-> Local File
这个直接依赖给切了。变为 Model <-> CRDT <-> Local File
。Node.js端负责CRDT <-> Local File
同步。前端剩下Model <-> CRDT
。即文件保存不由前端调用RPC方法来实现(FileSchemeDocClientService.saveByContent
),而是后端自己同步CRDT与文件来实现。
现有情况下,Monaco Model会与本地文件进行同步。(BaseFileSystemEditorDocumentProvider
)
比如:频繁地改动保存本地文件。IDE前端右下角会出现文件不同步的报错。
当然,工作量会不小。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个 PR 主要是考虑非协同场景的 BUG,目前单用户加载了协同模块会出现通过 git 等操作修改代码后再打开文件,内容被恢复了。 协同场景的文件变更同步还需要修改 FileWatcher,现在文件监听在协作场景还有 BUG,需要单独开一个 Issue 解决了
本地测试过,这个修复暂时没有问题。
Codecov ReportBase: 57.85% // Head: 57.76% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## v2.22 #2260 +/- ##
==========================================
- Coverage 57.85% 57.76% -0.10%
==========================================
Files 1319 1316 -3
Lines 83421 83104 -317
Branches 17401 17289 -112
==========================================
- Hits 48260 48001 -259
+ Misses 31937 31905 -32
+ Partials 3224 3198 -26
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
这条分支上没有这里的commit #2246 需要合并过来才知道影响 |
理论上没有影响,相关代码没有变更 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/publish |
🎉 PR Next version 2.22.2-next-1675996470.0 publish successful! You can install prerelease version via
/home/runner/work/_temp/_runner_file_commands/step_summary_3b8e27c8-47db-41f3-b3ef-bcb107ad898d |
/publish |
🎉 PR Next version 2.22.2-next-1676022353.0 publish successful! You can install prerelease version via
/home/runner/work/_temp/_runner_file_commands/step_summary_a0ba745e-bb34-4d5c-9394-a79eadda134f |
Types
Background or solution
#2238
问题原因是在打开文件时,协同模块会根据 yTextMap 内容更新文档,文件窗口关闭后通过其他方式直接修改文件后,yTextMap 内容未更新,导致打开文件时,依然是上次关闭的内容