Refactoring should be easier to abort

Originator:dtweston
Number:rdar://34982040 Date Originated:13-Oct-2017 11:29 AM
Status:Open Resolved:
Product:Developer Tools Product Version:9.1 beta 2
Classification:Serious Bug Reproducible:Always
 
Summary:
When one attempts to use Refactor > Extract All Occurrences or Extract Variable

and then changes one’s mind, it should be easier to cancel the proposed refactoring



Steps to Reproduce:
1. Select a piece of code to refactor.
2. Select Refactor.
3. Select either Extract Method, Extract Variable or Extract All Occurrences.
4. Press Escape to abort the refactoring.

Xcode interprets this as accepting the default (or current) name of the new entity (which is nonsense because the name is horrible) and you need to Undo to get back to the previous state.

Alternatively,
4. Press ⌘Z to abort the refactor.

In this case, Xcode deletes the newly inserted entity, but leaves the original code still selected, so continuing to type causes you to create a reference to something that no longer exists.

Expected Results:
Pressing Escape when Xcode is asking you to name a new entity created via refactoring should abort the Refactoring step entirely and restore the original code. It should not be necessary to Undo anything.

Pressing ⌘Z while Xcode is asking you to name a new entity created via refactoring should only abort changes you made to the new entity’s name. I.e. changing `extractedFunc` to `blah` and then hitting ⌘Z should return you back to `extractedFunc`.

Bonus points: touch bar support during refactoring would help.

Actual Results:
All kinds of bad stuff happens. when trying to cancel a refactor (as described above).

Version:
9.1 beta 2

Notes:
I additionally attempted to record a screen cast of Xcode’s behavior in this circumstance, but because QuickTime Player overtakes the touch bar, there’s no more Escape button for me to press while recording.

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!