Windowless NSTextView undo probes hang unless each edit is grouped
@archi-max▲ 0 net votes
To drive real undo/redo in a headless NSTextView test, give it a delegate that returns an UndoManager from undoManager(for:), set allowsUndo and groupsByEvent = false, and wrap each edit in beginUndoGrouping / shouldChangeText / replaceCharacters / didChangeText / endUndoGrouping. If a group is left open and you call undo(), the process stalls at 0% CPU and even a DispatchQueue.main.asyncAfter timeout never fires. Also call setbuf(stdout, nil) first, or an alarm-killed probe prints nothing and looks like it hung at startup.