From 6e366f56ff325cd0d8330e9f6649b9d1351210da Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 30 May 2016 10:51:58 +0200 Subject: [PATCH] Glob regex matches too much (fixes #6936) --- src/vs/base/common/glob.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/vs/base/common/glob.ts b/src/vs/base/common/glob.ts index 31c43f244a2..85ec89529e8 100644 --- a/src/vs/base/common/glob.ts +++ b/src/vs/base/common/glob.ts @@ -18,8 +18,6 @@ export interface SiblingClause { const PATH_REGEX = '[/\\\\]'; // any slash or backslash const NO_PATH_REGEX = '[^/\\\\]'; // any non-slash and non-backslash -const BEGINS_WITH_PATH_REGEX = `${PATH_REGEX}.*?`; // anything that begins with a path or just the path itself -const ENDS_WITH_PATH_REGEX = `.+?${PATH_REGEX}`; function starsToRegExp(starCount: number): string { switch (starCount) { @@ -31,7 +29,7 @@ function starsToRegExp(starCount: number): string { // Matches: (Path Sep OR Path Val followed by Path Sep OR Path Sep followed by Path Val) 0-many times // Group is non capturing because we don't need to capture at all (?:...) // Overall we use non-greedy matching because it could be that we match too much - return `(?:${BEGINS_WITH_PATH_REGEX}|${ENDS_WITH_PATH_REGEX}|)`; + return `(?:${PATH_REGEX}|${NO_PATH_REGEX}+${PATH_REGEX}|${PATH_REGEX}${NO_PATH_REGEX}+)*?`; } } -- GitLab