Xcode 9: Automatically insert closing braces option fails with Allman style coding

Originator:mail.junjie
Number:rdar://32808574 Date Originated:June 16 2017, 2:00 PM
Status: Resolved:
Product:Developer Tools Product Version:Version 9.0 beta (9M136h)
Classification:UI/Usability Reproducible:Always
 
Summary:
In Allman style coding where the opening brace of a control statement within a function is placed on a new line, Xcode 9 fails to insert the closing brace automatically. In K&R style where the opening brace is placed on the same line of its respective control statement, Xcode 9 inserts the closing brace as expected. Watch attached video or attempt to type sample code into a function in Xcode/

Sample code:

	if (1)
	{
		// no closing brace inserted for Allman style
	}
	
	if (1) {
		// closing brace inserted automatically in K&R style
	}

Steps to Reproduce:
1. Ensure "Automatically insert closing braces option" is enabled in Xcode > Preferences > Text Editing > Editing
2. Attempt to type the following code within a function and observe how Xcode fails to automatically insert the closing brace in the first style:

	if (1)
	{
		// no closing brace inserted for Allman style
	}
	
	if (1) {
		// closing brace inserted automatically in K&R style
	}

Expected Results:
Closing brace for a control statement inserted automatically regardless of where the opening brace is placed.

Observed Results:
Closing brace for a control statement is not inserted automatically when the opening brace is placed on a new line

Version:
Version 9.0 beta (9M136h)
macOS 10.12.4 (16E195)

Notes:


Configuration:

Comments

Bug still exists on production version of XCode 9!


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!