refactor(diffs): Give diff hunk recompute a single owner per edit#905
refactor(diffs): Give diff hunk recompute a single owner per edit#905necolas wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39c1326d55
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| result.baseThemeType = themeType; | ||
| this.renderCache.isDirty = true; | ||
| return changedAdditionLines; |
There was a problem hiding this comment.
Keep hunk recompute for deferred edit tokens
When a content-only edit lands outside a virtualized diff's current render range, EditorTokenizer delivers that changed line through Editor.#onDeferTokenize, whose only cache hook is updateRenderCache(lines, themeType). Since this method now just returns the changed addition lines and the deferred caller ignores the return value, the background/offscreen path updates diff.additionLines but never calls recomputeContentHunks; scrolling to that edited line later can render it with stale hunk metadata (for example as unchanged context instead of a new change). The synchronous visible-edit path was updated to consume the return value, but the deferred path still needs an owner for the recompute.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in aea8a2b. The deferred/offscreen tokenize path (Editor.#onDeferTokenize) now recomputes hunks for the changed lines via a new recomputeContentHunks (recompute only, no view refresh), so a content-only edit that lands outside the render window keeps its hunk metadata in sync instead of dropping the recompute after the token/recompute split. The visible rows are still patched separately, and line-count edits remain handled by applyDocumentChange.
updateRenderCache is now a token-content sync that returns the addition lines whose text changed; the hunk recompute moves to a dedicated recomputeContentHunks method. The host drives the recompute explicitly per edit: applyContentEdit (recompute + refresh) for visible content edits, recomputeContentHunks (recompute only) for content edits the background tokenizer delivers offscreen, and applyDocumentChange (full) for line-count changes. Removes the skipDiffRecompute and shouldRefreshView parameters and the coordination they required. No behavior change.
e74fd7f to
aea8a2b
Compare
updateRenderCache is now a token-content sync that returns the addition lines whose text changed; the incremental hunk recompute moves to recomputeContentHunks, surfaced through a new method applyContentEdit. The host drives exactly one recompute path per edit: applyContentEdit (incremental) for in-place content edits and applyDocumentChange (full) for line-count changes. Removes the skipDiffRecompute and shouldRefreshView parameters and the coordination they required. No behavior change.