fix(editor): stop external file syncs from stranding the dirty marker (#3165) - #3185
Merged
wgqqqqq merged 1 commit intoSep 22, 2026
Merged
Conversation
External writes to an open file (AI agent, git checkout, scripts) refreshed the buffer correctly but left the tab showing "modified": the global content change listener recomputed isDirty on every setValue with no way to tell a disk sync apart from a user edit, and the clean-up markAsSaved ran in a microtask that an unmount race could skip entirely. - MonacoModelManager gains a beginExternalSync/endExternalSync bracket: while open, content changes skip the dirty recompute and the transient dirty-changed broadcast; unbalanced endExternalSync calls are no-ops so suppression can never get stuck on. - updateModelContent(markAsSaved=true) brackets its setValue and broadcasts dirty-changed(false), making the clean transition visible to consumers the same way setValue made the dirty one visible. - CodeEditor brackets the programmatic setValue in applyExternalContentToModel and settles markAsSaved synchronously in the disk-sync and encoding-reload paths instead of deferring to a microtask. Closes GCWing#3165
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Fixes #3165。外部程序(AI 代理、git checkout、脚本)改写已打开的文件后,编辑器缓冲区会正确刷新,但标签页仍然挂着「已修改」标记,而用户没有做过任何编辑。
根因
脏状态链路把「程序化同步」当成「用户编辑」处理,共三处:
改动
issue 建议 2(脏状态单一来源化)是跨组件重构,改动面大,本 PR 不包含,可后续单独讨论。
验证
Testing level: fully tested(本地)。
AI-assisted 说明:实现与测试由 AI 编码代理协助完成,以上验证均在本地 checkout 实跑。