Repository navigation
Fold unicode case and ignore inline drift markers - #748
Merged
Merged
Conversation
Signed-off-by: Neemias Cormino Manso <130704790+n33miaz@users.noreply.github.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Signed-off-by: Neemias Cormino Manso <130704790+n33miaz@users.noreply.github.com>
Signed-off-by: Neemias Cormino Manso <130704790+n33miaz@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.
Summary
This PR fixes two issues in the drift detection module (
crates/core/src/drift.rs):Unicode case folding for stale phrase matching: The
sweepfunction previously usedto_lowercase()which doesn't handle Unicode case folding correctly. For example, the German sharp S (ß, U+00DF) would not matchSSorssbecauseto_lowercase()leavesßunchanged while convertingSStoss. The fix adds a customcasefoldfunction that properly handles:ß→ssΣ,σ,ς) →σIgnore inline marker examples: The
block_offunction previously usedline.contains("<!-- ads:begin")which would match marker-like text appearing inline in code blocks or documentation (e.g.,`<!-- ads:begin123 -->`in a Rust code example). The fix introduces anis_marker_linehelper that only recognizes markers on standalone lines (after trimming), ignoring inline examples.Changes
casefoldfunction incrates/core/src/drift.rsfor proper Unicode case foldingsweepfunction to usecasefoldinstead ofto_lowercase()is_marker_linehelper to detect only standalone marker linesblock_ofto useis_marker_lineinstead of substring matchingRegression Tests
The following tests fail without the fix and pass with it:
crates/core/tests/drift.rs::stale_phrase_unicode_case_folding_matches_sharp_s_and_ss- verifiesßmatchesstrasse/STRASSEcrates/core/tests/drift.rs::stale_phrase_unicode_case_folding_matches_greek_sigma- verifies Greek sigma variants matchcrates/core/tests/drift.rs::inline_marker_example_in_code_block_is_ignored- verifies inline begin marker in code block is ignoredcrates/core/tests/drift.rs::inline_end_marker_example_in_code_block_is_ignored- verifies inline end marker in code block is ignoredcrates/core/tests/drift.rs::inline_marker_example_in_documentation_is_ignored- verifies inline marker in documentation is ignoredcrates/core/tests/drift.rs::real_standalone_marker_still_detected_after_inline_examples- verifies real markers still work after inline examplesAll 19 drift tests pass, including the 6 new regression tests.
How to validate
cargo test -p ads-core --test drift(all 19 tests green).Regression test: crates/core/tests/drift.rs::stale_phrase_unicode_case_folding_matches_sharp_s_and_ss fails without the fix
Refs #589