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):
Actual output (entire line dropped):
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:
- When
/* and */ appear on the same line, keep code before /* and after */
- When
/* opens without */, keep code before /* and enter block comment mode
- When
*/ closes a multi-line comment, keep code after */
Description
The
MinimalFilterinsrc/core/filter.rsdrops valid code when a line contains an inline block comment. Lines likeint x = 5; /* comment */are entirely skipped — the code before the/*is lost.Reproduction
Input (C/Java/JS/TS/Go/Rust):
Expected output (minimal filter strips comment, keeps code):
Actual output (entire line dropped):
Also affects multi-line comment closings
Input:
Expected:
int z = 3;andint w = 4;both kept.Actual:
int z = 3;is dropped.Root Cause
Lines 174-186 in
filter.rssetin_block_comment = truewhen/*is found, then unconditionallycontinue(skip the entire line), even when the comment is only part of the line.Impact
rtk read --filter minimalsilently drops valid code on lines with inline block commentsFix
Restructure the block comment handler to:
/*and*/appear on the same line, keep code before/*and after*//*opens without*/, keep code before/*and enter block comment mode*/closes a multi-line comment, keep code after*/