Skip to content

Let a backslash make a leading +, -, ! or ^ literal in a glob token [patch] - #200

Merged
matt-edmondson merged 3 commits into
mainfrom
fix/198-escape-token-prefix
Nov 11, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
fix/198-escape-token-prefix

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #198

What changed

ExtractGlobFilterTokens always treated a token's first character as a prefix. Because of that, an item named +page.svelte couldn't be found by typing its name, and !important.txt or ^notes.md let every item through.

  • Escape: a backslash before a leading +, -, ! or ^ makes that character literal.
    • \+page.svelte is the optional token +page.svelte.
    • The escape also works after a prefix: +\+page* is the required token +page*, and -\-draft* is the excluded token -draft*.
    • A backslash anywhere else is still a path separator, so src\main.cs matches as before.
  • GetHint(TextFilterType.Glob): now says that ! and ^ also exclude, and explains the escape.
  • README: a new "Glob Tokens" section lists the three token kinds and every prefix, with the backslash escape and the [+] class workaround.

Behaviour change

A glob token that starts with \ followed by a prefix character used to mean "a path separator, then that character". It now means the literal character. Matching a leading separator followed by + still works with [\\]+… or /+….

Tests

  • Each of the four prefix characters, escaped, finds exactly its item. So do \+page* and [+]page.svelte.
  • An escaped prefix after a required prefix and after an excluded prefix.
  • Unescaped +, -, ! and ^ still mean required or excluded.
  • A backslash before an ordinary character is still a path separator.
  • The GetHint expectation is updated.

With the unescape stubbed out, 9 of the new cases fail. With the fix, every new test passes. dotnet test gives 279/280. The one failure, ReadmeTests.EveryMethodInTheReadmeApiReferenceExistsWithItsDocumentedDefaults, also fails on main (5f420d9) without this change.

As the triage noted, open PRs that edit README.md and ReadmeTests.cs may textually conflict with this one. No other open PR changes how prefixes are parsed.


Generated by Claude Code

…patch]

A glob token's first character was always read as a prefix, so an item
named +page.svelte or !important.txt could not be found by typing its
name. A backslash before a leading prefix character now makes it literal,
also after a + or - prefix. GetHint and the README list every prefix the
parser recognises and the escape.

Fixes #198

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3WKJyQMZaWCcyzKVK
…patch]

The README API test required every overload's same-named parameter to carry
the documented default. The binary-compatibility overloads from #166 have no
defaults by design, so main has been red since #178. They are marked
[EditorBrowsable(Never)] and are not what the README documents, so the default
check now skips them. A wrong default on a visible overload still fails.

Fixes #183

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW6FzBtSrY5LKUuDYce
(cherry picked from commit 9328e00)

Copy link
Copy Markdown
Contributor Author

This PR inherits the ci / .NET / Test failure that's on main (5f420d9), where ReadmeTests.EveryMethodInTheReadmeApiReferenceExistsWithItsDocumentedDefaults already fails. I've cherry-picked the existing fix from open branch fix/183-readme-api-test-compat-overloads (9328e00) as dc50700. With it, dotnet test passes 280/280 locally.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

The SonarCloud gate (Maintainability D on new code) has the same cause as on #199. The only analysis of main is from 2026-11-04 (837b460), because every CI run on main since then has failed on the README test. "New code" therefore includes the four pre-existing S3427 BLOCKERs on the TextFilter.BinaryCompatibility.cs overloads and the S3776 in ExpandGlobClasses, and this PR touches neither. The findings on lines this PR adds are seven INFO-level MSTEST0068 suggestions (CollectionAssert.AreEqual → Assert.AreSequenceEqual) in the new tests. The rest of the suite also uses CollectionAssert.AreEqual, and changing those seven alone would not lift the rating to A.

The gate should clear once #186 merges, main goes green, and SonarCloud re-baselines.


Generated by Claude Code

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

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 737f463 into main Nov 11, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/198-escape-token-prefix branch November 11, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants