Skip to content

Faster sideways scroll with a syntax colour cache, and a codebase cleanup - #9

Closed
rednafi wants to merge 8 commits into
review-passfrom
scroll-cache
Closed

rednafi wants to merge 8 commits into
review-passfrom
scroll-cache

Conversation

@rednafi

@rednafi rednafi commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Stacked on #8.

  • Sideways scroll is faster. rexdiff keeps the syntax colours between renders, so it does not colour the same lines again. In Rex, six scroll keys on a 5,000-line file take 0.07 s instead of 0.17 s in Changes, and 0.11 s instead of 1.16 s in Files. The screens are the same as before.
  • On a deleted line, e opens the editor at the nearest new line instead of line 1.
  • The code is tidier. The editor commands and the safe-text helpers move into small internal packages, so tui only uses them. vcs.PullRequest cleans the pull request text itself. Comments use plain English, and test failures tell what they want.

A sideways scroll renders the diff again, and each render highlighted
every line again with chroma. diff.Cache keeps the highlighted lines, and
the tui keeps one Cache for all renders. On a 5,000-line file, a scroll
key takes 8 ms in place of 20 ms with the folds closed, and 11 ms in
place of 180 ms in the Files tab.
On a deleted line, e opened the file at line 1. It now opens at the
first new line below the cursor, else the last new line above it.
A file with an unknown name gets its lexer from the content, and that
scan took 30 ms on each render of a 5,000-line file. Also simplify the
cache comments and the benchmark.
…diff

- internal/editor builds the editor command, so tui only runs it.
- internal/termtext has Plain and Quote, which diff exported before.
- vcs.PullRequest removes control characters from the text itself, so
  every caller gets safe text.
Comments use the present tense, one idea in each sentence, and lines of
80 columns or fewer. Each test failure message tells what it got and
what it wants. No code changes.
- editor.Template, editor.Program, and editor.ShellQuote replace
  FromTemplate, FromEditor, and Quote.
- The View reads the lexer from its Cache only.
- Fix a doc link to termtext.Quote.
@rednafi rednafi mentioned this pull request Oct 25, 2026
@rednafi

rednafi commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

Merged into master through #10.

@rednafi rednafi closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant