Xcode 9.2: Editor extension cancellationHandler not called

Originator:invalidname
Number:rdar://35859513 Date Originated:12/5/17
Status:open Resolved:
Product:developer tools Product Version:9.2
Classification:serious bug Reproducible:always
 
Summary: The cancellationHandler of this Xcode source editor extension is not being called when the extension is cancelled from the XCode UI.

Steps to Reproduce:
1. Build the attached project EmojifierDemo.zip. This is a trivial Xcode source editor extension to convert patterns like :thumbsup: to their corresponding emoji.
2. Change schemes to the source editor extension and run it. Choose Xcode as the host app. This will launch a second copy of Xcode with the grayed-out icon.
3. In the child instance of Xcode, navigate to a source file, and do Editor > EmojifierExtension > Emojify!
4. The extension is built to waste time with a Thread.sleep(forTimeInterval: 5) after each replacement pattern. This is plenty of time for the cancellation banner to appear. Click the "Cancel (x)" button in the banner. 

Expected Results:
1. Code in the cancellation handler should run. This calls NSSound.beep(), and prints "cancelled" to the log. If a breakpoint is set in the cancellation handler closure, the parent instance of Xcode should stop on it.

Actual Results:
1. The beep is not heard, the logging message is not seen, and the breakpoint is not hit.
2. print() messages from the remaining replacement strings continue to be printed to the debugging pane, long after the cancel button has been tapped.

Version/Build:
Xcode Version 9.2 (9C40b).

Configuration:
Mac Pro (Late 2013)
macOS High Sierra 10.13.1 (17B1003)

Comments


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!