fix(transposed_space): deduplicate suggestions that differ only by case#3463
fix(transposed_space): deduplicate suggestions that differ only by case#3463jlaportebot wants to merge 1 commit into
Conversation
The helper used exact string comparison, so canonical capitalization forms like "The cat" and raw forms like "the cat" were both added as suggestions when the space transposition could be interpreted both ways. Switch to case-insensitive comparison via eq_ignore_ascii_case so only the canonical form is kept. Fixes Automattic#3355
|
Didn't I also submit a PR for this a few days ago? Or was that for a similar but different issue? Since you are (using) a bot perhaps you can update the prompt/algorithm to check for pending PRs? There's a bit of a backlog at the moment. |
|
Thanks for pointing out #3356 — I hadn't checked for existing PRs before opening this. Your fix addresses the same root cause. I'm happy to close this in favor of your PR if you'd like, or if the maintainers prefer one approach over the other. My apologies for the duplicate effort — I'll add a pre-check for existing open PRs going forward. |
Let's keep them both open. @elijah-potter is a better Rust coder than me and is the only one that can give a PR final approval so I've requested his review and when he has time I'm sure he will pick the better implementation. |
|
All CI checks pass. Ready for review when maintainers have a moment. |
|
Superseded by #3356. |
Problem
The
TransposedSpacelinter can offer the same suggestion twice when the canonical capitalization form (e.g. "The cat") and the raw form (e.g. "the cat") both match — they differ only in case but were treated as distinct suggestions.Fixes #3355.
Fix
Changed
keep_uniqueto use case-insensitive comparison (eq_ignore_ascii_case) instead of exact string matching. This ensures that when the canonical form and raw form are the same word with different casing, only the canonical version is kept as a suggestion.Testing
Added two new tests using
assert_suggestion_count:no_duplicate_suggestions_case_insensitive— verifies "Thec at" produces exactly 1 suggestion, not 2no_duplicate_suggestions_space_early— verifies "Th ecat" produces exactly 1 suggestion, not 2Existing tests continue to pass (verified with
cargo check -p harper-core).