fix(read): preserve template literals in aggressive filter#2430
Open
axelray-dev wants to merge 1 commit into
Open
fix(read): preserve template literals in aggressive filter#2430axelray-dev wants to merge 1 commit into
axelray-dev wants to merge 1 commit into
Conversation
Signed-off-by: axelray-dev <110029405+axelray-dev@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2421
What changed
AggressiveFilter::filter()did not track template literal (backtick) state. Lines inside multi-line JS/TS template literals that didn't match keep-patterns (imports, function signatures, const/let, braces) were silently dropped, corrupting the output.The fix adds
in_template_literalstate tracking. Each line's backtick count is checked: an odd count toggles the state. Lines inside template literals are always preserved regardless of pattern matching.Tests
3 new tests added to
src/core/filter.rs:test_aggressive_filter_preserves_multiline_template_literal-- multi-line template with#contenttest_aggressive_filter_preserves_template_literal_expressions--${...}interpolationtest_aggressive_filter_preserves_multiple_template_literals-- two separate template literals in one fileFull suite:
cargo test --all-- 2153 passed, 0 failed, 8 ignored.Verification
All clean. DCO signed.