Skip to content

When typing enter after a double slash, the line-breaking javascript code is automatically commented out by mistake #242658

Closed
@zheung

Description

@zheung

What happen

I found this issue in the Insider version, but it also reproduced easily in the web version.

I discovered this when I tried to move object's properties to a new line.
There is a regular expression ending in a slash before the cursor, and it just so happens that there are two consecutive slashes in the text. Causing the text after the cursor to be recognized as a line of comments?

Example Code

const a = {
	// regex ends with   ↓↓ 'double' dash
	str: ''.replace(/^\.\//, ''), i_wiil_be_commented_if_you_keyup_enter: 'what?!',

	// not ends with      ↓ 'double' dash
	str: ''.replace(/^\.\./, ''), i_wiil_not_be_commented_if_you_keyup_enter: 'well',
};

Screen recording

screen-record

Web VSCode Version:

Version: 1.97.2
Commit: e54c774
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Embedder: vscode.dev

Insider VSCode Version:

VS Code version: Code - Insiders 1.98.0-insider (6609ac3, 2025-03-04T19:22:25.096Z)
OS version: Windows_NT x64 10.0.19045

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugeditor-autoindentEditor auto indentation issuesjavascriptJavaScript support issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions