Skip to content

perf: skip full-buffer joins on cursor motion - #14

Merged
nooga merged 1 commit into
mainfrom
perf-long-files
Sep 18, 2026
Merged

nooga merged 1 commit into
mainfrom
perf-long-files

Conversation

@nooga

@nooga nooga commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Cache a char vector and per-line start offsets against :lines identity so paren-match / electric-pair / indent nth instead of string/join + count/subs on every keystroke (cursor motion does not rebuild).
  • Scanners accept that vector without recopying; char-at is nth, not subs.
  • display-col walks only up to point; line-display-window still maps the whole line for spans but only builds the visible slice of expanded text.

Test plan

  • lg test/run.lg
  • Open a multi-thousand-line file, move around with paren-match on — no hitch on each C-n/C-p
  • A very long line: horizontal scroll (C-e / C-a) still paints tabs/caret notation correctly and the cursor lands on the right column
  • Typing ) still highlights the matching opener; ( still looks forward

Made with Cursor

Paren-match used to string/join and count every line on every key;
cache a char vector against :lines identity, and only expand the
visible slice of long lines for display.

Co-authored-by: Cursor <cursoragent@cursor.com>
@nooga
nooga merged commit a10f825 into main Sep 18, 2026
1 check passed
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