pref(editor): Introduce postponeBackgroundTokenizeToNextFrame method for the DiffsEditor#766
Open
ije wants to merge 7 commits into
Open
pref(editor): Introduce postponeBackgroundTokenizeToNextFrame method for the DiffsEditor#766ije wants to merge 7 commits into
postponeBackgroundTokenizeToNextFrame method for the DiffsEditor#766ije wants to merge 7 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce UI freezes during editor-driven rerenders (selection updates, scrolling, and component renders) by deferring/pacing background tokenization work to the next animation frame and tightening the tokenizer’s background scheduling.
Changes:
- Added
postponeBackgroundTokenizeToNextFrame()to theDiffsEditorAPI and invoked it during render and selection/scroll operations. - Enhanced
EditorTokenizerbackground processing with pause/resume support and message listener lifecycle management, plus added tests for these behaviors. - Updated
syncWithRenderto use an explicitcomponentType('file' | 'file-diff') instead of an edit mode flag.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/diffs/test/editorTokenizer.test.ts | Adds coverage for background-tokenization listener lifecycle, pause/resume, and message validation. |
| packages/diffs/src/types.ts | Extends DiffsEditor with componentType and the new postpone method. |
| packages/diffs/src/editor/tokenzier.ts | Implements pause/resume, safer message parsing, and attaches the message listener only while background tokenization runs. |
| packages/diffs/src/editor/editor.ts | Stores component type, adds postponeBackgroundTokenizeToNextFrame(), and calls it during selection/scroll handling. |
| packages/diffs/src/components/FileDiff.ts | Uses componentType 'file-diff' and postpones background tokenization during render. |
| packages/diffs/src/components/File.ts | Uses componentType 'file' and postpones background tokenization during render. |
| apps/demo/src/main.ts | Enables editor debug logging in the demo for easier validation of scheduling changes. |
Comments suppressed due to low confidence (2)
packages/diffs/src/components/File.ts:481
syncWithRenderis called withthis.lineAnnotations(aLineAnnotation[]), but the editor/tokenizer pipeline expects diff-style annotations (DiffLineAnnotationwith aside). Provide a defaultsidewhen passing annotations to the editor (e.g. treat file annotations as additions) so the types and downstream editor helpers stay consistent.
editor.syncWithRender(
'file',
highlighter,
fileContainer,
file,
this.lineAnnotations,
this.renderRange
);
packages/diffs/src/components/File.ts:670
- Same issue as the other
syncWithRendercall:this.lineAnnotationslacks asidebut the editor expectsDiffLineAnnotation. Add a defaultsidewhen forwarding annotations so the editor can safely track and update them across edits.
editor.syncWithRender(
'file',
highlighter,
fileContainer,
file,
this.lineAnnotations,
this.renderRange
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
when doing re-render(selection/code) postpone the background tokenizing to next frame. this can avoid UI freezing for a large file editing.