Exception during undo after typing marked text (accent characters)

Number:rdar://FB7717993 Date Originated:2020-05-29
Status:Open Resolved:No
Product:iOS Product Version:iOS 13.5
Classification:Crash Reproducible:Always
The attached sample project shows a text view that contains detailed information about this issue (in the text view and in its README.rtf). Run it in iOS Simulator for iPad.

In short: When you enter an accented character via marked text at the end of a text view and then hit ⌘Z, an exception is raised.

To reproduce the crash, simply follow these steps (assumes a US keyboard layout):
• Run this sample project in the iOS Simulator for iPad.
• Click the “Capture Keyboard” button in the toolbar of the simulator (not sure if this is necessary, but keyboard shortcuts seem to work more reliable with this activated).
• There’s a text view shown. At the end of the text, type ⌥E to insert an accent character (´). Note that the text view inserts the accent as marked text.
• Type e so the marked text is replaced with é
• Hit ⌘Z to undo
• Crash 💥

Expected behavior:
Undo the change.

Actual behavior:

Tested on in iOS Simulator for iPad Air (3rd generation), iOS 13.5, Xcode 11.5 (11E608c)


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!