SIGN IN SIGN UP

Speed up large selection deletes (#107)

Doing select-all + delete in the Ode to STTextView in the example Text
Editor was beach balling badly for a few seconds on my machine. This fix
speeds it up dramatically.

Sampling showed deleteBackward spending most of its time materializing
the deleted text for the yank ring through
NSTextLayoutManager.substring(in:). For a large selection, that walks
the range through TextKit substring enumeration before the actual
deletion happens.

Use the backing attributed string from NSTextContentStorage to read the
deleted text directly by NSRange instead. This keeps yank behavior
intact without paying the layout-manager substring cost on every large
delete.

The existing undo coverage now includes delete-then-yank so the fast
path is still checked against the expected deleted text.
B
Brandon Bloom committed
d08a18f51cd57022cc6d69281bd92a0e7f01b5ed
Parent: 041b171
Committed by GitHub <noreply@github.com> on 3/20/2026, 7:23:55 PM