Repository navigation
fix colorer handling of nonzero lexer backup deltas - #377
Merged
Merged
Conversation
When the token containing an edit has a nonzero backup delta, split-backward backs up over earlier tokens, but it returned the end and mode of the earliest token it removed while keeping the invalid tree that begins after the first token it removed. The colorer then treated the kept tokens as starting too early, so its stop check could splice them in at the wrong position. Also, at a token boundary split/data removes the token ending at the edit but reports only the later token's data, so the earlier token's backup delta was ignored. Fixes racket#376 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Resyntax analyzed 2 files in this pull request and found no issues.
Member
|
I can't say I really understand this code, but looking at the diff, I do think that I've used this for about a day in my drracket and am not seeing any problems. |
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.
@rfindler or @mflatt 1 — Fixes #376. Both bugs are in
split-backwardincolor:text-mixin, which decides what to re-lex after an edit.Below are explanations of what split-backwards is doing to cause each of the 2 bugs, with examples that use the new tests (and the
line-backup-lexerused in the tests).To reiterate from #376, the key thing about the lexer in the tests is that it uses the starting column of every token as its backup value (except for line-ending whitespace which gets backup=0). Which means any token getting re-lexed should start again from the beginning of the line.
Bug 1: backing up moves the kept position too
Bug 2: at a token boundary, the loop checks the wrong token's backup
Tests
The PR adds three tests to
gui-test/framework/tests/color-text.rkt. All three fail without this change:backing-up-lexeronaaabcaaabc, inserting at position 4 (bug 1). The existing test makes the same edit inaaabc, where no tokens follow the edit.line-backup-lexerwhose tokens back up to the start of their lineI manually ran the full
gui-testsuite on 9.3 CS/macOS against this change before and after. All framework tests pass. The only failures I had were intests/gracketand don't involve the colorer:wxme.rktneeds racket/snip@b7aab95, which Racket 9.3 doesn't have, andtest.rkthas two frame-position checks (get-y: expected 21; got 1) (which maybe is because I'm running dual monitors?)The explanations for each bug were technically drafted by the clanker (hence blockquotes), which also coded the fixes to
split-backwards. This was unfamiliar territory for me, so I spent a few hours testing things myself in DrRacket to be sure I understood them, and editing the explanations for clarity.Footnotes
I pinged you since it seems that @-mentioning a reviewer is apparently best practice now (see Expand the current pull request template to help draft better pull requests racket#5625, discourse 1, 2) ↩