Repository navigation
fix(macos): 修复大型 Java 文件编辑与滚动卡顿 - #621
Conversation
…or issue 561" This reverts commit 28c0916.
|
[P1/P2] 整体文本替换后,旧 fold state 会继续作用在新文本上,直到异步 Java structure 返回。 建议 review 文案: On a full-text replacement we keep the previous collapsed ranges active until the async structure refresh completes. rebuildLineIndex() only marks fold attributes dirty; it does not clear collapsedRanges, so the new document can temporarily hide unrelated text and highlight() also excludes those stale ranges. Could we synchronously clear the old fold state before highlighting the replacement, then restore folds when the new structure arrives? A regression test should check that no old range remains hidden immediately after replacing the whole document. [P2] 非 Java 文件现在每次编辑都会在 80ms 后额外重染一次整个 viewport。 建议 review 文案: scheduleFoldRefresh() also runs for non-Java edits, and its non-Java branch calls clearJavaStructure(). Now that clearJavaStructure() unconditionally invalidates syntaxHighlightState and calls highlight(), every non-Java keystroke gets a second viewport-wide syntax repaint ~80 ms later. Previously this path was effectively a no-op when there was no Java state. Can we keep the syntax invalidation/repaint Java-only here so non-Java files retain the existing edited-line refresh behavior? [P2] foldAttributesNeedRefresh 判定太宽,会把“fold geometry 没变”的等长编辑重新送回全文 layout。 建议 review 文案: This marks fold attributes dirty for any edit before the end of the last collapsed range, even when the edit is a same-length replacement completely outside every fold. In that case the parser can return identical fold geometry, but foldAttributesNeedRefresh still forces the full-document invalidateLayout/ensureLayout path. Could this be limited to edits that actually intersect a collapsed range (and let geometryChanged handle shifted ranges)? A same-length edit before a collapsed method would be a useful regression case. [P2] 初次打开带 import fold 的 Java 文件时,light mode 可能先被缓存成 dark syntax colors。 建议 review 文案: primeJavaImportFold() runs before Coordinator.isDarkAppearance is initialized from the current palette, but applyFoldState() now calls highlight(). Since the coordinator defaults to dark appearance, opening a Java file with imports in light mode can cache the initial viewport using dark-theme syntax colors; the following correctly configured highlight() then sees those ranges as already painted. Could we initialize the coordinator appearance before priming the fold, or avoid highlighting from that pre-appearance path? 我另外把几个容易误报的点排除了:semantic interval index 的查询/producer precedence 没发现 correctness 问题;Core 生成的 Java fold hidden range 确实从 opening line 之后开始,所以新 gutter 用行首检查隐藏状态这点可以成立。 Core 对 imports、comments 和 brace folds 都是按这个契约生成的。 |
大型 Java 文件在滚动、光标重绘和结构结果返回时,会在主线程反复遍历全部折叠区域、全文着色并强制全文排版。本次让折叠箭头复用可见行几何,并把 Java 语义着色纳入视口缓存,降低持续滚动与结构结果应用的停顿。
Fixes #561
完整的初始复现报告、单变量实验、配套测量 JSON 和正式修复复测结果见对应 issue 评论。
修复内容
滚动继续使用现有 AppKit 绘制循环及视口通知合并机制,没有新增高频 SwiftUI 状态写入或父页面重建。
验证
git diff --check通过。6709b9a9的完整 Release 应用使用 8329 行、447 KiB 合成 Java 文件完成三轮修复复测,包含真实 JDT LS 开启组;15 次可见颜色检查、4644 个 token 比较均匹配。本轮 review 修复通过上述回归测试和 Release 构建验证,未重复该性能矩阵。具体计时、对照超时及测量口径见上方 issue 评论。./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh ./scripts/verify-service-boundaries.sh git diff --check ./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh \ --report .artifacts/test-stability/issue-561-review2-final.json -- \ --filter 'Editor|TextViewport|SyntaxHighlight|highlightedRange' ./scripts/build-macos.sh --configuration release --triple arm64-apple-macosx本地使用 macOS 27.0 / Apple Silicon / Swift 6.3.3,仓库要求的 Swift 6.2 工具链链接失效。未取得原业务源码,也未搭建原报告中的多模块 Maven 工程;Windows 未变更。完整验证限制已记录在 issue 评论中。测试应用、子进程和本次创建的 JDT LS 缓存均已清理。