Address performance problems for StructuredText code blocks#8
Conversation
|
@codex please review this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bf43d8cc4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .task(id: code) { | ||
| await model.tokenize(code: code, languageHint: languageHint, theme: theme) |
There was a problem hiding this comment.
Include highlighter theme in tokenization task identity
When a code block is first rendered with .plain or another theme whose tokenProperties is empty, tokenize now intentionally skips Prism and stores only a single plain token; if the same view later receives a syntax-highlighting theme for the same code string, this .task(id: code) does not run again, so the block stays un-tokenized and cannot apply token colors. This affects apps that switch themes dynamically via highlighterTheme(_:); key the task on the tokenization inputs that now include the theme/tokenProperties (or otherwise retrigger tokenization when an empty-token theme changes to a highlighting theme).
Useful? React with 👍 / 👎.
|
@codex please fix the issues you noted in the comments |
|
Summary
Testing
|
9bf43d8 to
4b284b3
Compare
Cherry-picked from gonzalezreal/textual PR gonzalezreal#39
Improves reliability of StructuredText when rendering large code blocks and makes Textual more suited to streaming content.