Skip to content

Fix glob pattern matching on Windows#37

Open
maya-maddox wants to merge 1 commit into
jacob-j:mainfrom
maya-maddox:main
Open

Fix glob pattern matching on Windows#37
maya-maddox wants to merge 1 commit into
jacob-j:mainfrom
maya-maddox:main

Conversation

@maya-maddox

Copy link
Copy Markdown

Problem

Glob patterns don't work on Windows. For example:

"folder-path-color.folders": [
    { "path": "src/*", "color": "blue" },
    { "path": "**/test", "color": "red" }
]

Expected Behavior

Glob patterns like src/* or **/test should match folders on all platforms.

Actual Behavior

On Windows, glob patterns never match. Only exact paths (e.g., "path": "src/MyProject") work, because they use the .includes() fallback.

Root Cause

The relative path is computed using:

const relativePath = path.relative(root, uri.fsPath).replace(/\\/g, '/');
  • root is a URI path (e.g., /C:/Users/...)
  • uri.fsPath is a native Windows path (e.g., C:\Users\...)

path.relative() between these two different formats produces an incorrect result on Windows, so minimatch never matches.

Fix

Use uri.path instead of uri.fsPath, so both paths are in the same URI format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant