Repository navigation
fix(better-files): colour files and code blocks outside render - #44
Open
sebastian-quack wants to merge 1 commit into
Open
sebastian-quack wants to merge 1 commit into
sebastian-quack wants to merge 1 commit into
Conversation
Opening a few hundred lines of HTML failed with "This view could not be rendered ... interrupted": the viewer coloured the whole file inside render(), and Herdr's QuickJS interrupts a render that runs too long. The whole-file pass now runs about 4,000 characters per 16ms timer tick (at least one line) from the viewer's own timer, with state carried between steps, and redraws once complete. The budget counts characters, not lines, since a line's cost is its length. Until then rows are coloured one at a time as drawn, as files over 5,000 lines already were. Markdown code blocks go through the same queue and show plain until coloured. A version that changes mid-way is dropped, so a row never shows another file's runs.
This branch has not been deployed
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.
Summary
Opening a 466-line
index.htmlin Better Files showed this instead of the file:lineRunscolours the whole file insiderender(). Node does that in 43 ms, but QuickJS is much slower and Herdr interrupts a render that runs too long. Markdown code blocks (codeRuns) had the same problem.Colouring now runs outside render, from the viewer's existing 300 ms tick:
syntax.jsis unchanged, so it stays identical to Better Changes'. The RECIPE describes the new pass and adds a Watch out note.Evidence
main'sviewer.js:# pass 109 / # fail 4index.htmlopens and is coloured in the app.node --test better-files/tests/*.cjsgives# pass 113 / # fail 0.herdr-app checkpasses.New test: 121 lines of TypeScript (about 8,400 characters) open with a block comment. Colouring takes 3 steps (2 of them after a tick), the comment still carries into line 121, and a version replaced mid-way never gets runs. A second new test: a 4,500-character line takes a step to itself, and the next line follows a tick later. Two existing tests now run the colouring steps before they check colours (
color(h)). The code-block test also checks that a block is plain before its colours are in.Merge Danger
Door: two-way
Colouring code only, with no stored state and no new settings. Reverting restores the old behaviour.
Blast Radius: cosmetic
A file or code block shows uncoloured, or coloured row by row, for a few ticks after it opens or changes: about 8 ticks of 16 ms for the 32,000-character file above.