Skip to content

Import incorrectly dropped when correcting string template expression with redundant braces #2615

@rsmith20

Description

@rsmith20

Expected Behavior

Given

import java.io.File.separator

val s = "${separator} is a file separator"

upon formatting it should be

import java.io.File.separator

val s = "$separator is a file separator"

Observed Behavior

Instead, the import is deleted

val s = "$separator is a file separator"

Your Environment

  • Version of ktlint used: 1.2.1
  • Relevant parts of the .editorconfig settings: ktlint_code_style = intellij_idea
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): repros with CLI ktlint as well as intelliJ plugin.

Work Around

Manually re-add imports or fix redundant braces before formatting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions