Skip to content
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: document status may out of sync #3954

Merged
merged 8 commits into from
Aug 23, 2024
Merged

fix: document status may out of sync #3954

merged 8 commits into from
Aug 23, 2024

Conversation

bytemain
Copy link
Member

@bytemain bytemain commented Aug 20, 2024

Types

  • 🐛 Bug Fixes

Background or solution

插件层状态不同步,做一下各种时机的同步

主要是做了两件事情:

  1. 防止 model ref 被不小心持有,导致磁盘中的文件更新反应不到 browser 层
  2. 非 dirty 的文件在被保存时会往 ext 层同步 dirty 状态

Changelog

Summary by CodeRabbit

  • 新特性
    • 引入了新的可选属性 dirty,用于表示文档是否存在未保存的更改,增强了文档状态管理。
    • 增加了异步方法 syncDocumentModelToExtThread,改进文档模型与外部线程的同步。
  • 改进
    • 修改了文档保存逻辑,确保在文档存在时无条件调用保存方法,提高了操作的一致性。
    • 精化了文档状态更新的事件处理逻辑,增强了事件触发的鲁棒性。

Copy link

railway-app bot commented Aug 20, 2024

🚅 Previously deployed to Railway in the core project. Environment has been deleted.

@bytemain bytemain changed the base branch from main to v3.2 August 20, 2024 07:06
@opensumi opensumi bot added the 🐞 bug Something isn't working label Aug 20, 2024
Copy link
Contributor

coderabbitai bot commented Aug 20, 2024

Walkthrough

本次修改增强了文档同步和保存过程的功能,添加了新的异步方法以更新文档模型的状态,确保即使文档未更改,外部表示依然保持同步。此外,接口结构被扩展,以支持文档的脏状态标识,改进了文档管理的清晰度和可维护性。

Changes

文件路径 更改摘要
packages/editor/src/browser/doc-model/... 新增异步方法 syncDocumentModelToExtThread,修改 save 方法以在文档未修改时同步状态。
packages/editor/src/browser/doc-model/types.ts IEditorDocumentModelOptionChangedEventPayload 接口中新增可选属性 dirty
packages/extension/src/browser/vscode/api/... MainThreadExtensionDocumentData 中新增 dirty 属性,增强文档状态跟踪。
packages/extension/src/browser/vscode/api/... MainThreadWorkspace 中为 fileSearchService 添加类型注解,增强类型安全性。
packages/extension/src/common/vscode/doc.ts IExtensionDocumentModelOptionsChangedEvent 中新增可选属性 dirty
packages/extension/src/hosted/api/vscode/... 改进 ExtensionDocumentDataManagerImpl 逻辑,更新语言和脏状态处理,移除不必要的类型断言。

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 38.75000% with 49 lines in your changes missing coverage. Please review.

Project coverage is 54.83%. Comparing base (1e0967c) to head (3b20884).
Report is 29 commits behind head on main.

Files Patch % Lines
packages/editor/src/browser/hooks/useEditor.ts 20.00% 8 Missing ⚠️
...ges/editor/src/browser/workbench-editor.service.ts 45.45% 4 Missing and 2 partials ⚠️
...tor/src/browser/doc-model/editor-document-model.ts 0.00% 4 Missing and 1 partial ⚠️
packages/editor/src/browser/untitled-resource.ts 0.00% 3 Missing and 2 partials ⚠️
...ges/search/src/browser/tree/search-tree.service.ts 0.00% 4 Missing and 1 partial ⚠️
packages/search/src/browser/search.service.ts 0.00% 3 Missing and 1 partial ⚠️
...ages/editor/src/browser/fs-resource/fs-resource.ts 40.00% 2 Missing and 1 partial ⚠️
...src/browser/merge-conflict/merge-conflict.model.ts 25.00% 3 Missing ⚠️
...sion/src/hosted/api/vscode/doc/doc-manager.host.ts 0.00% 1 Missing and 2 partials ⚠️
packages/search/src/browser/replace.ts 25.00% 1 Missing and 2 partials ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3954      +/-   ##
==========================================
+ Coverage   54.75%   54.83%   +0.07%     
==========================================
  Files        1561     1558       -3     
  Lines       96435    95193    -1242     
  Branches    19973    19498     -475     
==========================================
- Hits        52804    52199     -605     
+ Misses      36130    35720     -410     
+ Partials     7501     7274     -227     
Flag Coverage Δ
jsdom 50.27% <38.75%> (+0.07%) ⬆️
node 15.53% <0.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bytemain bytemain changed the title fix: sync document status when save fix: document status maybe out of sync Aug 21, 2024
@bytemain bytemain changed the base branch from v3.2 to main August 22, 2024 12:22
@bytemain bytemain changed the title fix: document status maybe out of sync fix: document status may out of sync Aug 23, 2024
Copy link
Member

@erha19 erha19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bytemain
Copy link
Member Author

这个也只是缓解编译器相关状态同步问题,具体不同步原因还要再继续查

@bytemain bytemain merged commit b13dc21 into main Aug 23, 2024
16 checks passed
@bytemain bytemain deleted the fix/sync-doc-status1 branch August 23, 2024 02:31
Ricbet pushed a commit that referenced this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants