text: Commit background parses that a newer streamed chunk overtook - #4
Merged
Merged
Conversation
Taken from longbridge#3344 (FenjuFu), not yet merged there. A background parse result used to be dropped whenever its revision was not the latest. A stream that appends faster than a parse completes had always moved on, so nothing landed until the stream stopped. A result parsed since the text was last replaced is a prefix of the current text, and is now committed. One from before that replacement, or older than what is already committed, is discarded. Reconciled with this fork's own changes: - The receiving task reads the state first, so that a result it discards is not an update. It now uses the same rule (`takes_parse_of`). - `commit_parsed_update` hands the result to the fork's `commit_parse`. - The fork parses a small append on the UI thread, so the two tests build on a paragraph long enough to send the append to the background parser. Co-Authored-By: Claude Code
trancong12102
force-pushed
the
sync/text-parse-overtaken
branch
from
October 1, 2026 16:46
75d03bd to
5ca864e
Compare
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.
Takes longbridge#3344 (open upstream) ahead of its merge, reconciled with #3.
Bug. A text view dropped every background parse whose revision wasn't the latest. In a fast stream, every parse is overtaken by the next chunk before it lands, so nothing landed until the stream stopped. In this fork that applies to appends the UI thread doesn't parse itself: a last block plus appended text over
MAX_SYNC_PARSE_BYTES, which a long streamed answer reaches.Fix. Upstream's rule: commit a result parsed since the last replacement that is newer than what's committed.
Reconciled with #3:
takes_parse_of), so a discarded result is still not an update.commit_parsed_updatehands the result to the fork'scommit_parse.stream_commits_a_parse_that_a_newer_chunk_overtookfails under the old rule.cargo test -p gpui-base --lib text::: 335 pass.When longbridge#3344 merges upstream, take its version and keep this reconciliation.
Written with Claude Code.