Skip to content

Bug: MinimalFilter drops code on lines with inline block comments (code loss) #2714

Description

@guyoron1

Description

The MinimalFilter in src/core/filter.rs drops valid code when a line contains an inline block comment. Lines like int x = 5; /* comment */ are entirely skipped — the code before the /* is lost.

Reproduction

Input (C/Java/JS/TS/Go/Rust):

int x = 5; /* inline comment */
int y = 10;

Expected output (minimal filter strips comment, keeps code):

int x = 5;
int y = 10;

Actual output (entire line dropped):

int y = 10;

Also affects multi-line comment closings

Input:

/* multi-line
   comment */ int z = 3;
int w = 4;

Expected: int z = 3; and int w = 4; both kept.
Actual: int z = 3; is dropped.

Root Cause

Lines 174-186 in filter.rs set in_block_comment = true when /* is found, then unconditionally continue (skip the entire line), even when the comment is only part of the line.

Impact

  • Code loss: rtk read --filter minimal silently drops valid code on lines with inline block comments
  • Affects all C-style languages: C, C++, Java, JavaScript, TypeScript, Go, Rust
  • Particularly dangerous because the code is silently removed — no warning or error

Fix

Restructure the block comment handler to:

  1. When /* and */ appear on the same line, keep code before /* and after */
  2. When /* opens without */, keep code before /* and enter block comment mode
  3. When */ closes a multi-line comment, keep code after */

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions