From 9293f7b1e8553886db69ea3cced3b110468c75be Mon Sep 17 00:00:00 2001 From: molsonkiko <46202915+molsonkiko@users.noreply.github.com> Date: Sat, 8 Jul 2023 11:34:13 -0700 Subject: [PATCH] fix bug: leading * did not cause treatment as glob --- NppNavigateTo/Glob.cs | 2 +- NppNavigateTo/Tests/GlobTester.cs | 7 +++++++ test_results.txt | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NppNavigateTo/Glob.cs b/NppNavigateTo/Glob.cs index 9f5a2fc..06c8b17 100644 --- a/NppNavigateTo/Glob.cs +++ b/NppNavigateTo/Glob.cs @@ -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 @@ -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 == '*') { diff --git a/NppNavigateTo/Tests/GlobTester.cs b/NppNavigateTo/Tests/GlobTester.cs index c43caee..027b132 100644 --- a/NppNavigateTo/Tests/GlobTester.cs +++ b/NppNavigateTo/Tests/GlobTester.cs @@ -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) diff --git a/test_results.txt b/test_results.txt index dd6924d..c0521dd 100644 --- a/test_results.txt +++ b/test_results.txt @@ -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