-
Notifications
You must be signed in to change notification settings - Fork 344
Description
Swift version
swift-6.2.3-RELEASE
Platform
macOS Sequoia 15.4.1
Editor
Visual Studio Code with Swift extension 2.16.0
Description
When using semantic highlighting, escaped characters in string literals are not highlighted in a separate color. The (default) TextMate grammar-based syntax highlighting creates separate tokens for escaped characters.
With semantic highlighting:
Without semantic highlighting, using the TextMate grammar-based highlighting:
VSCode token debug hover showing the different token types:
I’m aware that sourcekit-lsp currently only forwards semantic tokens provided by sourcekitd / swift-syntax, and does not perform additional tokenization itself.
That said, it seems possible for this behavior to be implemented at the LSP level by augmenting or post-processing semantic tokens, even if the upstream tokens do not currently distinguish escaped characters.
However, I’m unsure whether this is the correct layer to address this issue. It may be more appropriate to implement this upstream. This would avoid splitting the tokenization logic across multiple projects. But I don't know which other projects consume the tokens and if it is thus possible / feasible to change this upstream.
I am open to working on this and creating a PR.
Steps to Reproduce
- Ensure semantic highlighting is turned on in VSCode:
"editor.semanticHighlighting.enabled": true - Open a Swift file with a string containing escaped characters, for example
let a = "test \n \r \\ \' \""
Logging
No response