Closed mitchymitch closed 9 months ago
Hey, thanks for all the detail in this report! Before we proceed, would you mind doing some debugging to narrow down the problem?
It looks like your HighlightedTextEditor
has a couple TextFormattingRule
s attached to it. Try removing those one by one. If removing a TFR stops the crashes, there's probably a bug in that code.
The issue could also be happening because of RegexLetterChunks
. Maybe try with a different NSRegularExpression
.
The issue could also be from the other items in the VStack
or the fixedSize
modifier. I'm not sure!
Hey I removed all the attached stuff on the HighlightedTextEditor
and that didn't change anything, but it was the underline rule which made it crash. Removing this stopped the crash:
TextFormattingRule(key: .underlineStyle) { content, range in
guard graph[content] != nil else { return [] }
return NSUnderlineStyle.single.rawValue
}
Nice! Glad to hear that fixed it.
Thanks for looking at this - just curious, did I get the return type right in that NSUnderlineStyle
TextFormattingRule
above?
Under the covers, TextFormattingRule
s call addAttribute()
on one big NSAttributedString
. I think NSUnderlineStyle.single.rawValue
is a valid value for .underlineStyle
. I don't know if []
is valid. It's an older, untyped API so you'd have to check the docs for NSAttributedString
.
The code also could've crashed in that graph[content]
check.
You probably have to keep narrowing it down to the specific part of that TFR to find the crash.
DO NOT DELETE THIS TEMPLATE
If you do not fill out this template, your issue will be automatically closed.
Describe the bug When pressing on the editor to try edit the text, it crashes. I tried swapping back out with a TextEditor and the crash doesn't happen.
To Reproduce
Expected behavior I am able to edit the text view.
Screenshots
Environment
Additional context