Skip to content

perf(editor): restyle a long line without typesetting it again - #4475

Merged
datlechin merged 2 commits into
mainfrom
perf/jv3-restyle-long-line
Nov 24, 2026
Merged

datlechin merged 2 commits into
mainfrom
perf/jv3-restyle-long-line

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • Attribute-only edits on a wrapped line restyle the touched fragments in place (new CTLines, same breaks) instead of typesetting the whole line. A width, height or mark change falls back to a typeset, as before.
  • TextLayoutManager.fragmentTextRange(covering:): the first and last line count only the fragments in view. VisibleRangeProvider uses it, so a highlight query on a 1 MB line covers the visible chunks, not the whole line.
  • findOffsetAtPoint no longer assumes a fragment's CTLine string range starts at the fragment start.
  • Item JV3 of perf(json): cell popover, long-line restyle and harness items left from #4427 #4442. Gate (quiet pass 2): 2 typesets a step, 164 ms main a step, 1 MB one-line INSERT, word wrap on.
  • Before/after, 1.08 M character wrapped line, color of 4,096 characters, Debug, package test: 188 ms (full typeset) vs 23 ms (restyle plus layout). Not measured in the app.
  • Not run: the app build (worktree has no generated project); CI covers it.

Test plan

  • New TextLayoutManagerRestyleTests: untouched fragments keep their CTLine, touched ones swap; marks match a full typeset; bold width change retypesets; click offset unchanged; fragment range is the band; unlaid line counts whole.
  • VisibleRangeProviderTests: a long wrapped line gives a small visible set.
  • swift test in TableProEditor: all pass.

@datlechin
datlechin enabled auto-merge (squash) November 24, 2026 12:22
@datlechin
datlechin merged commit 9cf15f0 into main Nov 24, 2026
11 checks passed
@datlechin
datlechin deleted the perf/jv3-restyle-long-line branch November 27, 2026 16:37
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