File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -146,8 +146,21 @@ - (BOOL)tryExpandingSwitchStatement
146146 // Generate the items to insert and insert them at the end
147147 NSMutableString *replacementString = [NSMutableString string ];
148148
149- if ([switchContent stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet ]].length == 0 && ![[SCXcodeSwitchExpander sharedSwitchExpander ] isSwift ]) {
150- [replacementString appendString: @" \n " ];
149+ NSString *trimmedContent = [switchContent stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet ]];
150+
151+ if (trimmedContent.length == 0 ) {
152+ // remove extraneous empty lines if existing content is only whitespace
153+ if (switchContent.length > 0 ) {
154+ [textView insertText: @" " replacementRange: switchContentRange];
155+ closingBracketLocation -= switchContent.length ;
156+ switchContentRange.length = 0 ;
157+ [replacementString appendString: @" \n " ];
158+ } else {
159+ // keep Swift code compact
160+ if (![[SCXcodeSwitchExpander sharedSwitchExpander ] isSwift ]) {
161+ [replacementString appendString: @" \n " ];
162+ }
163+ }
151164 }
152165
153166 for (IDEIndexSymbol *child in [((IDEIndexContainerSymbol*)symbol).children allObjects ]) {
You can’t perform that action at this time.
0 commit comments