Repository navigation
Load diff editors only when needed - #19
Merged
Merged
Conversation
Previously every non-binary file in the diff carried edit: true, so CodeView attached a full editor to each file that scrolled into view. Each partial patch-parsed diff then hydrated immediately through loadDiffFiles: a full-contents fetch (flashing the 'Loading editor…' indicator), an in-place metadata upgrade, and a whole-file re-highlight. On large diffs this ran for every file while scrolling, and again after every live patch refresh. Files now enter edit mode on the first click into their code (the same click-and-type flow as before). Scrolling no longer creates editors, fetches file contents, or re-highlights full files, and the editor module itself loads on first edit intent instead of at startup. The caret is placed on the clicked line once the editor's document is hydrated, and number-column clicks keep driving comment line selection. Commit, discard, and diff-source switches end the open edit sessions.
The first click into a file focused the editor at the start of the clicked line. Measure the character offset under the pointer from the clicked line element (Range-based binary search over its text nodes, so token spans, tabs, and wrapped lines measure correctly) and pass it to Editor.focus once the document hydrates.
Use caretPositionFromPoint in Chrome and Firefox and caretRangeFromPoint in Safari instead of measuring every character rectangle. These browser APIs already account for token spans, tabs, wrapping, and shadow DOM. Fall back to the start of the clicked line when no native caret is available.
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.
Summary
CodeView previously attached an editor to every text file as it entered the viewport. For partial diffs, attachment fetched the full file and highlighted it again. Scrolling through a large diff therefore caused visible lag and repeated "Loading editor…" messages. Live patch refreshes could repeat the same work.
The viewer now marks a file editable after the first click in its code. Scrolling no longer fetches full file contents or creates editors. The editor module also loads on demand.
The first click uses the browser's native caret hit test to preserve its line and character position. Line-number clicks still select lines for comments. Binary and deleted files remain read-only.
Checks
pnpm run lintpnpm run format:checkpnpm test(86 tests)pnpm run build:ui