Skip to content

Ignore leading and trailing spaces in a fuzzy filter [patch] - #129

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/fuzzy-ignores-filter-padding-115
Sep 29, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/fuzzy-ignores-filter-padding-115

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #115

Changes

  • The Fuzzy arm of IsMatch now trims the filter (filter.AsSpan().Trim()) before calling Fuzzy.Contains. Before this, " hel" matched nothing and "hel " matched only items that contain a space.
  • The triage suggested leaving token splitting for Fuzzy (honouring TextFilterMatchOptions) to a separate change, so this PR does not include it.

Tests

  • FuzzyIsMatchIgnoresFilterPadding checks that "hel ", " hel" and " hel\t" give the same result as "hel" for each candidate text.
  • FuzzyFilterIgnoresFilterPadding checks that Filter with a padded fuzzy filter returns [hello world, helium, help].
  • With the fix reverted, 5 of these cases fail. With the fix, the full suite passes (142/142). The library builds for all target frameworks (netstandard2.0/2.1, net8/9/10).

🤖 Generated with Claude Code

https://claude.ai/code/session_01RpyD4tJtfe5diTxv8UEw2x


Generated by Claude Code

The Fuzzy arm of IsMatch passed the filter through as typed, so padding
became a space the text had to contain: " hel" matched nothing and
"hel " matched only items with a space. The filter is now trimmed first,
as Glob and Regex already effectively do by splitting on whitespace.

Fixes #115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RpyD4tJtfe5diTxv8UEw2x
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit aac6f21 into main Sep 29, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/fuzzy-ignores-filter-padding-115 branch September 29, 2026 01:06
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.

Fuzzy filter with a leading or trailing space hides every item: " hel" matches nothing, "hel " matches only items containing a space

2 participants