Skip to content

Commit

Permalink
fix bug: leading * did not cause treatment as glob
Browse files Browse the repository at this point in the history
  • Loading branch information
molsonkiko committed Jul 8, 2023
1 parent 63ee60e commit 9293f7b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NppNavigateTo/Glob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public Regex Glob2Regex(string inp)
sb.Append("\\\\");
break;
case '*':
uses_metacharacters = true;
if (is_char_class)
{
sb.Append("\\*"); // "[*]" matches literal * character
Expand All @@ -114,7 +115,6 @@ public Regex Glob2Regex(string inp)
break; // since globs are only anchored at the end,
// leading * in globs should not influence the matching behavior.
// For example, the globs "*foo.txt" and "foo.txt" should match the same things.
uses_metacharacters = true;
next_c = Peek(inp);
if (next_c == '*')
{
Expand Down
7 changes: 7 additions & 0 deletions NppNavigateTo/Tests/GlobTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ public static void Test()
("aд.txt", false),
("д.md", false),
}),
("**.txt | *.json", new[]
{
("Z:\\foo.json", true),
("c:\\goon\\guk.txt", true),
("foo.jsonl", false),
("c:\\bar.txto", false),
}),
};
var glob = new Glob();
foreach ((string query, var examples) in testcases)
Expand Down
2 changes: 1 addition & 1 deletion test_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Test results for NavigateTo v2.6
Testing Glob syntax
=========================

Ran 90 tests and failed 0
Ran 94 tests and failed 0

0 comments on commit 9293f7b

Please sign in to comment.