Skip to content

fix: normalize path separators for Windows compatibility#693

Open
thomaslaich wants to merge 1 commit intonumtide:mainfrom
thomaslaich:fix/windows-globbing
Open

fix: normalize path separators for Windows compatibility#693
thomaslaich wants to merge 1 commit intonumtide:mainfrom
thomaslaich:fix/windows-globbing

Conversation

@thomaslaich
Copy link
Copy Markdown

@thomaslaich thomaslaich commented Apr 21, 2026

On Windows, file paths use backslashes (\) as separators. The gobwas/glob library expects forward slashes, so glob matching would silently fail for all Windows paths. This fix normalizes backslashes to forward slashes in pathMatches before matching, making formatter glob patterns work correctly on Windows. Tested on Windows 11.

By the way: It seems like the library is not officially released on Windows. We use pixi and download treefmt from conda-forge which has for some reason a win-64 binary available.

@thomaslaich thomaslaich marked this pull request as ready for review April 21, 2026 21:13
Comment thread format/glob.go
}

func pathMatches(path string, globs []glob.Glob) bool {
path = strings.ReplaceAll(path, "\\", "/")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i use filepath.ToSlash(path) instead?

Copy link
Copy Markdown
Member

@brianmcgee brianmcgee Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think this is the better approach.

@brianmcgee
Copy link
Copy Markdown
Member

Thanks for the contribution. I'd like to support Windows but I haven't used it in any kind of serious way in over a decade which is why we currently don't have any releases setup for it. Getting some windows CI setup has been on my task list for a long time now.

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.

2 participants