Skip to content

Refactoring "Convert string literal to minimal number of '#'s" produces incorrect source code #2465

@jansorg

Description

@jansorg

Swift version

6.2.3

Platform

Arch Linux

Editor

Visual Studio Code Swift plugin 2.14.2 and also my own JetBrains plugin (Noctule)

Description

Refactoring "Convert string literal to minimal number of "#"s" does not handle string literals correctly, which would have to have escaped characters after the conversion.

Steps to Reproduce

Place the text cursor into the string literal and then invoke the refactoring "Convert string literal to minimal number of "#"s"

let x = #"""#

The file is then turned into this, which is incorrect because the previously literal double quote `"' is now unescaped:

let x = """

I think either the refactoring should not be offered or the result should be properly escaped.

Logging

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions