Skip to content

Built-in Swift language configuration treats all occurrences of // as line comments #298057

Closed

Description

@award999

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.109.5
  • OS Version: All platforms

swiftlang/vscode-swift#1900 was open against the Swift Extension for VS Code. It looks like the built-in language configuration for Swift is causing this false positive line comment https://github.com/microsoft/vscode/blob/main/extensions/swift/language-configuration.json#L85.

Steps to Reproduce:

  1. Create a new *.swift file
  2. Insert the following code:
func test() {
  let someStrings = ["/something"]
  let _ = someStrings.map { $0.replacing(/\//, with: "") }
}
  1. Insert a new line before the }
  2. Observe the inappropriate comment

Activity

  1. RedCMD commented on Feb 27, 2026

    @RedCMD
    Contributor
  2. added
    bug
    on Feb 27, 2026
  3. award999 commented on Apr 2, 2026

    @award999
    Author
  4. RedCMD commented on Apr 2, 2026

    @RedCMD
    Contributor

    Aiday Marlen Kyzy (@aiday-mar) how about this ^\\s*//|// ?

    continue comment only if

    1. is a comment only line ^\s*//
    2. contains at least one space after the comment token //
    Image

    could also add has to contain whitespace before comment \s//

    https://github.com/search?q=lang%3Ats+%2F%5E%5Cs*%5CS.*%3F%5C%2F%5C%2F+%2F&type=code

  5. aiday-mar commented on Jun 12, 2026

    @aiday-mar
    Collaborator

    Hi RedCMD (@RedCMD) thanks for the comment and apologies for the late reply. Do you want to make a PR, or should I make one?

  6. added
    unreleased
    on Jun 14, 2026
  7. added
    insiders-released
    and removed
    unreleased
    on Jun 15, 2026
  8. added
    verified
    on Jun 15, 2026
  9. locked and limited conversation to collaborators on Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugeditor-autoindentinsiders-releasedverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions