Skip to content

Commit 9293f7b

Browse files
committed
fix bug: leading * did not cause treatment as glob
1 parent 63ee60e commit 9293f7b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

NppNavigateTo/Glob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public Regex Glob2Regex(string inp)
105105
sb.Append("\\\\");
106106
break;
107107
case '*':
108+
uses_metacharacters = true;
108109
if (is_char_class)
109110
{
110111
sb.Append("\\*"); // "[*]" matches literal * character
@@ -114,7 +115,6 @@ public Regex Glob2Regex(string inp)
114115
break; // since globs are only anchored at the end,
115116
// leading * in globs should not influence the matching behavior.
116117
// For example, the globs "*foo.txt" and "foo.txt" should match the same things.
117-
uses_metacharacters = true;
118118
next_c = Peek(inp);
119119
if (next_c == '*')
120120
{

NppNavigateTo/Tests/GlobTester.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ public static void Test()
160160
("aд.txt", false),
161161
("д.md", false),
162162
}),
163+
("**.txt | *.json", new[]
164+
{
165+
("Z:\\foo.json", true),
166+
("c:\\goon\\guk.txt", true),
167+
("foo.jsonl", false),
168+
("c:\\bar.txto", false),
169+
}),
163170
};
164171
var glob = new Glob();
165172
foreach ((string query, var examples) in testcases)

test_results.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Test results for NavigateTo v2.6
33
Testing Glob syntax
44
=========================
55

6-
Ran 90 tests and failed 0
6+
Ran 94 tests and failed 0

0 commit comments

Comments
 (0)