Open ilyapuchka opened 7 years ago
The length of source.lang.swift.stmt.case
including string interpolation seems to be wrong even if it does not contain unicode characters.
$ sourcekitten structure --text 'switch { default: return "\(true)" }'
…
"key.kind" : "source.lang.swift.stmt.case",
"key.length" : 27, // should be 25
"key.namelength" : 0,
"key.nameoffset" : 0,
"key.offset" : 9
…
string interpolation followed by unicode:
$ sourcekitten structure --text 'switch { default: return "\(true) π" }'
…
"key.kind" : "source.lang.swift.stmt.case",
"key.length" : 26, // should be 28
"key.namelength" : 0,
"key.nameoffset" : 0,
"key.offset" : 9
…
unicode before string interpolation:
$ sourcekitten structure --text 'switch { default: return "π \(true)" }'
…
"key.kind" : "source.lang.swift.stmt.case",
"key.length" : 30, // should be 28
"key.namelength" : 0,
"key.nameoffset" : 0,
"key.offset" : 9
…
This issue should be filed to bugs.swift.org.
sourcekitten structure
returns wrongkey.length
when unicode characters are used after string interpolation. Here is an example:sourcekitten structure --text 'class Foo { var blah: String { switch { default: return "\(true) π" }}}'
It will always give 26 for length of case statement:
At the same time when unicode character comes before string interpolation length is completely different.
sourcekitten structure --text 'class Foo { var blah: String { switch { default: return "π \(true)" }}}'
but again adding whitespaces after string interpolation does not change the length, which will probably lead to crash again.
Crash happens when trying to extract string for such statement from the source:
Reference https://github.com/krzysztofzablocki/Sourcery/issues/432