Skip to content

Double-forward slashes are treated like comments when they aren't #1900

@nicksloan

Description

@nicksloan

Describe the bug
If you have a line of code that features two consecutive forward slashes that are not a comment and insert a new line before the end of the line, a comment is inserted on the new line containing the remaining content of the original line.

To Reproduce
Steps to reproduce the behavior:

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

Expected behavior
A clear and concise description of what you expected to happen.

Environment

  • OS: MacOS Tahoe
  • Swift version (output of swift --version):
    Apple Swift version 6.2 (swift-6.2-RELEASE)
    Target: arm64-apple-macosx26.0
    Build config: +assertions
  • Visual Studio Code version: 1.105.0
  • vscode-swift version: 2.11.20250806

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds investigationIssue requires some investigation before it can be worked onup next

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions