Skip to content

fix(filter): preserve code around inline block comments#2715

Open
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/filter-inline-block-comment
Open

fix(filter): preserve code around inline block comments#2715
guyoron1 wants to merge 1 commit into
rtk-ai:developfrom
guyoron1:fix/filter-inline-block-comment

Conversation

@guyoron1

Copy link
Copy Markdown
Contributor

Summary

  • Fix MinimalFilter silently dropping valid code on lines with inline block comments
  • int x = 5; /* comment */ was entirely skipped — code before /* was lost (code loss bug)
  • Also affected closing lines of multi-line comments: comment */ int z = 3; dropped int z = 3;
  • Restructured block comment handler to extract and keep code before /* and after */, stripping only the comment itself

Before / After

Input Before After
int x = 5; /* inline */ line dropped int x = 5; kept
/* multi\nline */ int z = 3; int z = 3; dropped int z = 3; kept
/* full line comment */ line dropped line dropped (correct)

Test plan

  • Added test_inline_block_comment_preserves_code — verifies code before /* is kept
  • Added test_multiline_block_comment_closing_preserves_code_after — verifies code after */ is kept
  • Added test_full_line_block_comment_still_stripped — verifies full-line comments still removed
  • cargo clippy --all-targets passes
  • cargo test --all passes

Fixes #2714

MinimalFilter dropped entire lines containing inline block comments
like `int x = 5; /* comment */`, silently losing the code portion.
Also affected closing lines of multi-line comments when followed by
code.

Restructure the block comment handler to extract and keep code before
/* and after */, stripping only the comment itself.

Fixes rtk-ai#2714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant