Hello,
While writing a small console application I found this unexpected behaviour in readLine; it does not translate (or insert) the correct character for a suggestion. Instead, the returned String contains an unexpected character.
Try this small example (Xcode 11.5):
import Foundation
while true {
print(":> ", terminator:"")
let str = readLine(strippingNewline: false) ?? "#Empty#"
print(str)
}
In the debugging console (after the prompt ":>"), type:
(test
readLine will automatically insert the right parenthesis so that what's shown is
(test)
Now, move beyond the suggested right parenthesis with the right arrow key and press Enter.
The printed output is
(test?
with the question mark in a box.
I would have expected the right parenthesis to be returned even though it's an automated matching.
Is this intentional or is it a bug? Or is it some preference that I'm not aware of?
Best regards
/Patrik