Repository navigation
Fix syntax highlighting and editor performance in the scripting terminal - #81
Open
rubensworks wants to merge 12 commits into
Open
rubensworks wants to merge 12 commits into
rubensworks wants to merge 12 commits into
Conversation
Keywords were highlighted by substring, so they also matched inside other words (var in variable, return in returnValue), strings and comments, while strings, numbers and comments were not highlighted at all. Highlighting was also done per wrapped line, so it couldn't handle constructs spanning multiple lines. Tokenize the full script instead, with word boundaries, strings, numbers, and line and block comments, and add a markupScript method to language handlers for this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
The full script was wrapped and highlighted again on every key press, including cursor movement, scrolling and selection changes, which took 9 ms for a 500-line script and 41 ms for a 2000-line script. Cache the text layout until the text changes, and only build the styled text of visible lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
Coverage Report for CI Build 39109367309Coverage increased (+0.6%) to 43.978%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions439 previously-covered lines in 4 files lost coverage. Coverage Stats
💛 - Coveralls |
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
This was referenced Oct 17, 2026
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
…-performance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MRyTdV3fSV5Q5NPGep4q9
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.
Phase 5 of the scripting terminal UX improvements, stacked on #80 (then #79, #78, #77). One commit per item.
Improve syntax highlighting in the script editor
Problem: Highlighting matched keywords as substrings. In a dev client:
varinvariable,letinoutletand inside the string"let it be", andreturninreturnValueand inside a block comment were all highlighted as keywords..in1.5was highlighted as a symbol.COMMENTstyle existed.Change:
true,false,nullandundefineduse the existingCONSTANTstyle.ILanguageHandlergets a defaultmarkupScript(String)built onmarkupLine, so other handlers keep working.Only re-wrap and re-highlight the editor text when it changes
Problem: The whole script was wrapped and highlighted again on every key press, including cursor movement, scrolling and selection changes.
Change: The text layout is cached until the text changes, and styled text is only built for visible lines.
Measured in the dev client with lines of about 95 characters (each wraps to about 3 rows):
The arrow key "before" column includes the tokenizer from the first commit. On master, a full rebuild was 6.8 / 15.9 / 40 ms.
Dropped from the original plan
A monospace font: 4-space indentation is clearly readable in the normal font, so it would change the look without fixing a demonstrated problem.
Testing
./gradlew buildpasses, including the new unit tests../gradlew runGameTestServer: all 22 tests pass.Generated by Claude Code