You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 80adcd6
Browse filesBrowse the repository at this point in the historyBrowse files
Highlight diff hunks using the file lines above them
Summary:
The comparison view tokenizes each hunk on its own, starting from the grammar's initial state. When a hunk starts inside a multi-line construct, such as a template literal, triple-quoted string, or block comment, the closing delimiter is read as an opening one. Everything after it in the hunk then flips: code is colored as a string, and strings as code.
The fix fetches the lines of the "before" file above the last hunk, using the same `requestComparisonContextLines` message that expanding context already uses. The worker then tokenizes the unchanged lines between hunks and carries the grammar state into each hunk, on both sides. Lines between hunks are unchanged, so the same lines advance both sides' state.
- `tokenizeLinesFromState` in `shared/textmate-lib/tokenize.ts` starts from a given state and returns the state after the last line; `tokenizeLines` calls it with `INITIAL`.
- `SplitDiffTable` fetches up to 10,000 context lines when the view provides `fetchAdditionalLines`. Hunks are highlighted without context first, as before, and highlighted again once the lines arrive. Views without `fetchAdditionalLines`, files above the cap, and failed fetches (an error result or a rejected promise) keep the current behavior.
- `comparisonContextLines` now echoes the request's `start` and `numLines`, and the client matches on them. Before this, the client matched only on path, so two requests for the same file in flight at once (now more likely, since the view fetches context on open) could both resolve with the first response. Responses from older servers without these fields still match on path alone.
Reviewed By: cfirimar
Differential Revision: D125599812
fbshipit-source-id: 150b27f7493edbb929c128c51c17a2bed951fa2e
0 commit comments