`Matcher(case_sensitive=True)` still matches case-insensitively
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 80/100
Research direction
Both classes live in the textual.fuzzy module: start in Matcher.__init__, where the FuzzySearch is built without forwarding case_sensitive, then read FuzzySearch.match and its result cache, whose key ignores the flag. Reproduce with the snippet in the issue, make the cache respect case_sensitive (key it, or clear it when the attribute changes), and confirm Matcher("foo", case_sensitive=True).match("FOO") returns 0.0 while the insensitive search still returns 16.0.
Written by the indexing model from the issue text.
Description
Hi! I hit this while writing generated tests against Textual's widgets.
Matcher stores case_sensitive but makes its FuzzySearch with the default, so the setting has no effect. That also means Provider.matcher(user_input, case_sensitive=True) in a command palette provider is case-insensitive. Separately, FuzzySearch caches results by (query, candidate) only, so changing its case_sensitive attribute keeps returning the old results.
from textual.fuzzy import FuzzySearch, Matcher
matcher = Matcher("foo", case_sensitive=True)
print("Matcher(case_sensitive=True).match('FOO'):", matcher.match("FOO"))
print("matcher.fuzzy_search.case_sensitive:", matcher.fuzzy_search.case_sensitive)
search = FuzzySearch()
print("insensitive:", search.match("foo", "FOO"))
search.case_sensitive = True
print("after case_sensitive = True:", search.match("foo", "FOO"))
print("fresh FuzzySearch(case_sensitive=True):", FuzzySearch(case_sensitive=True).match("foo", "FOO"))
Output (the same on 8.2.7 and on main at 5e5b7ef):
Matcher(case_sensitive=True).match('FOO'): 16.0
matcher.fuzzy_search.case_sensitive: False
insensitive: (16.0, [0, 1, 2])
after case_sensitive = True: (16.0, [0, 1, 2])
fresh FuzzySearch(case_sensitive=True): (0.0, ())
I'd expect the first line to be 0.0, and the fourth to match the fifth.
Textual 8.2.7 and main (5e5b7ef), Python 3.13, macOS.
- Dominant language
- Python
- Stars
- 37.7k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Textualize/textual
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Textualize/textual#6790 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Textualize/textual#6789 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Textualize/textual#6787 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Textualize/textual#6782 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Textualize/textual#6778 · 1 comment ·
All issues in Textualize/textual
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GoogleCloudPlatform/professional-services-data-validator#1899 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mohanraj00/entelos#200 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
sweep
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
bketelsen/truenas-mcp#77 ·
Maintainers usually reply within 1 day
-
Console writes URL credentials to the local log, though AGENTS.md says secrets never reach diskOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
sandbox-quantum/switch#2163 ·
Maintainers usually reply within 1 day