Skip to content

TypeScript Code Organizer Deletes Commented-Out Code #107

@Christopher-C-Robinson

Description

@Christopher-C-Robinson

Title: TypeScript Code Organizer Deletes Commented-Out Code

Description:
The TypeScript Code Organizer extension is unexpectedly deleting commented-out code, particularly when there are consecutive comment lines or an empty line between them. This makes it difficult to temporarily disable code for debugging or iteration purposes.

Expected Behavior:

  • Commented-out code should remain in the file after formatting.
  • If a user explicitly comments something out, it should not be removed.

Actual Behavior:

  • The extension removes commented-out code in certain cases.
  • If a test or block of code is commented out at the end of a file, it gets deleted entirely instead of being preserved.
  • It seems that the extension interprets back-to-back comments (especially with a blank line between them) as unnecessary and removes them.

Steps to Reproduce:

  1. Comment out a block of code or a test at the end of a file.
  2. Run the VS Code TypeScript Code Organizer extension.
  3. Observe that the commented-out code is deleted.

Example:

Before running the organizer:

import { Selector } from "testcafe";

import Admin from "../../admin-variables";
import App from "../../app-variables";

//! Tests 1 through 16 are not concurrency enabled. Every test after that will be concurrency enabled

// Folders for this Suite
const folder1 = Admin.Navigation.AdvancedForms;
const folderOption = Admin.getFolderOption(folder1);
const roleOption = Selector('[id="ZZ Test Cafe-checkbox"]');

After running the organizer:

import { Selector } from "testcafe";

import Admin from "../../admin-variables";
import App from "../../app-variables";

//! Tests 1 through 16 are not concurrency enabled. Every test after that will be concurrency enabled
const folder1 = Admin.Navigation.AdvancedForms;
const folderOption = Admin.getFolderOption(folder1);
const roleOption = Selector('[id="ZZ Test Cafe-checkbox"]');

The comment // Folders for this Suite was removed.

Environment:

  • VS Code Version: 1.99.0-insider (user setup)
  • TypeScript Code Organizer Version: 2.0.10
  • OS: Windows_NT x64 10.0.22631
  • Electron: 34.2.0
  • Chromium: 132.0.6834.196
  • Node.js: 20.18.2
  • V8: 13.2.152.36-electron.0

Additional Context:

This behavior negatively affects debugging, test iteration, and temporary modifications. The ability to comment out code is essential, and having it automatically deleted is frustrating.

Would it be possible to adjust the logic so that all user comments are preserved unless explicitly removed?

Thanks for the great tool!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions