Skip to content

fix(transposed_space): deduplicate suggestions that differ only by case#3463

Closed
jlaportebot wants to merge 1 commit into
Automattic:masterfrom
jlaportebot:fix/transposed-space-duplicate-suggestions
Closed

fix(transposed_space): deduplicate suggestions that differ only by case#3463
jlaportebot wants to merge 1 commit into
Automattic:masterfrom
jlaportebot:fix/transposed-space-duplicate-suggestions

Conversation

@jlaportebot
Copy link
Copy Markdown
Contributor

Problem

The TransposedSpace linter 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_unique to 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 2
  • no_duplicate_suggestions_space_early — verifies "Th ecat" produces exactly 1 suggestion, not 2

Existing tests continue to pass (verified with cargo check -p harper-core).

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
@hippietrail
Copy link
Copy Markdown
Collaborator

hippietrail commented May 22, 2026

Didn't I also submit a PR for this a few days ago? Or was that for a similar but different issue?
Here it is: #3356

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.

@jlaportebot
Copy link
Copy Markdown
Contributor Author

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.

@hippietrail hippietrail requested a review from elijah-potter May 22, 2026 06:01
@hippietrail
Copy link
Copy Markdown
Collaborator

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.

@jlaportebot
Copy link
Copy Markdown
Contributor Author

All CI checks pass. Ready for review when maintainers have a moment.

@elijah-potter
Copy link
Copy Markdown
Collaborator

Superseded by #3356.

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.

The TransposedSpace linter can offer the same suggestion twice

3 participants