Xcode6-Beta4 (6A267n): Swift: Xcode editor incorrectly places text insertion point

Originator:mikeyward
Number:rdar://17803341 Date Originated:24-Jul-2014 07:47 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta4 (6A267n)
Classification:UI/Usability Reproducible:Always
 
Summary:
When calling a Swift function and passing in a variable/constant whose name is the same as the parameter name for which it is provided, Xcode’s editor mis-positions the caret after giving up on autocomplete, which leads to chopped textual content.

Example: http://cl.ly/1z372w1w301o/rdar.mov

Steps to Reproduce:
1) Type the following into a Playground: (the first two lines can be pasted, but the third should be typed to observe the bug)

let fooString = "foo!"
let allowedCharacters = NSCharacterSet.URLQueryAllowedCharacterSet()
let encodedRedirectURLString = fooString.stringByAddingPercentEncodingWithAllowedCharacters(allowedCharacters)

Expected Results:
typing “allowedCharacters” as the argument to stringByAdding… results in the text “allowedCharacters” between the parens.

Actual Results:
typing “allowedCharacters” as the argument to stringByAdding… results in the text “lowedCharactersal” between the parens.

Regression:
I have noticed this issue in all Xcode 6 betas to date.

Notes:
This does not seem to duplicate for all examples of function calls where the function parameter and passed-in variable have the same name, but it’s always reproducible for the symbols for which the bug does manifest.

The only workaround seems to be to type the desired text elsewhere and paste it into the desired location.

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!