Skip to content

[SR-16106] Once SourceKit-LSP supports formatting, run formatter on text inserted by CodeActions #496

Open
@adam-fowler

Description

@adam-fowler
Previous ID SR-16106
Radar None
Original Reporter @adam-fowler
Type Bug
Environment

swift-driver version: 1.45.2 Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)

Target: x86_64-apple-macosx12.0

Additional Detail from JIRA
Votes 0
Component/s SourceKit-LSP
Labels Bug
Assignee None
Priority Medium

md5: 46482d3680d87dc38282b4865db4ef55

Issue Description:

The following list of Code Actions do not include the correct spacing

  • Generate Member Initializer

  • Expand Switch Cases

  • Collapse Nested If Statements

  • Move to Extension

  • Extract Expression

  • Extract Repeated Expression

  • Extract Method

  • Convert To Switch Statement

For example if I have the following struct

struct Test {
    let a: Int
}

The "Generate Member Initializer" code action produces

struct Test {
internal init(a: Int) {
self.a = a
}
    let a: Int
}

I haven't been able to test all the refactor kinds so there may be others that need fixed as well.

"Add Equatable Conformance" is an example of a code action that generates the correct spacing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions