From dc7f1b280f77746dec8d72d133374ad744a45134 Mon Sep 17 00:00:00 2001 From: NgoQuocViet2001 Date: Tue, 29 Sep 2026 17:20:21 +0700 Subject: [PATCH] fix: let a middle ** in skipFiles match zero directories A `**` segment in the middle of a skipFiles glob compiled to `.*/`, which needs at least one extra directory. So `${workspaceFolder}/lib/**/*.js` did not skip `lib/index.js`, and a negation like `!**/foo/**/bar/**` did not un-skip `foo/bar/...`. Make that part optional so it matches zero or more directories, like the leading `**` already does. --- src/adapter/scriptSkipper/simpleGlobToRe.test.ts | 16 ++++++++++++++++ src/adapter/scriptSkipper/simpleGlobToRe.ts | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/adapter/scriptSkipper/simpleGlobToRe.test.ts b/src/adapter/scriptSkipper/simpleGlobToRe.test.ts index fee89847d..07c607306 100644 --- a/src/adapter/scriptSkipper/simpleGlobToRe.test.ts +++ b/src/adapter/scriptSkipper/simpleGlobToRe.test.ts @@ -46,6 +46,22 @@ describe('simpleGlobsToRe', () => { 'file:///hello/foo/bin/filename.js': false, }, }, + { + globs: ['**/foo/**/*.js'], + matches: { + 'file:///hello/foo/bar.js': true, + 'file:///hello/foo/bin/bar.js': true, + 'file:///hello/foobar.js': false, + }, + }, + { + globs: ['**/foo/**', '!**/foo/**/bar/**'], + matches: { + 'file:///hello/foo/bin/baz': true, + 'file:///hello/foo/bar/baz': false, + 'file:///hello/foo/bin/bar/baz': false, + }, + }, ]; for (const { globs, matches } of truthTable) { diff --git a/src/adapter/scriptSkipper/simpleGlobToRe.ts b/src/adapter/scriptSkipper/simpleGlobToRe.ts index 89f505295..5a0c89d74 100644 --- a/src/adapter/scriptSkipper/simpleGlobToRe.ts +++ b/src/adapter/scriptSkipper/simpleGlobToRe.ts @@ -48,7 +48,7 @@ function globToRe(glob: string, processPart = escapeRegexSpecialChars) { } else if (j === parts.length - 1) { // nothing more needed! } else { - regexParts.push('.*/'); + regexParts.push('(.*/)?'); // zero or more directories } } else { if (p.includes('*')) {