Skip to content

Commit 8a1b124

Browse files
Boshenclaude
andcommitted
fix: support case-insensitive file matching on Windows
On Windows, file paths are case-insensitive, so pattern matching should be case-insensitive as well. This fix normalizes both patterns and paths to lowercase on Windows before matching, while maintaining case-sensitive behavior on Unix systems. Changes: - Convert patterns to lowercase during normalization on Windows - Convert normalized paths to lowercase before matching on Windows - Use conditional compilation (#[cfg(target_os = "windows")]) - Add #[cfg_attr] to silence unused_mut warnings on non-Windows Fixes the test_case_insensitivity_windows test failure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5465eed commit 8a1b124

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/tsconfig/file_matcher.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,15 @@ impl TsconfigFileMatcher {
114114
fn normalize_patterns(patterns: Vec<String>, tsconfig_dir: &Path) -> Vec<String> {
115115
patterns
116116
.into_iter()
117-
.flat_map(|pattern| {
117+
.flat_map(|
118+
#[cfg_attr(not(target_os = "windows"), allow(unused_mut))]
119+
mut pattern
120+
| {
121+
// On Windows, convert to lowercase for case-insensitive matching
122+
#[cfg(target_os = "windows")]
123+
{
124+
pattern = pattern.to_lowercase();
125+
}
118126
// Convert absolute to relative
119127
#[allow(clippy::option_if_let_else)] // map_or would cause borrow checker issues
120128
let pattern = if Path::new(&pattern).is_absolute() {
@@ -180,11 +188,18 @@ impl TsconfigFileMatcher {
180188
pub fn matches(&self, file_path: &Path) -> bool {
181189
// Normalize path for matching
182190
#[allow(clippy::manual_let_else)] // Match is clearer here
183-
let normalized = match self.normalize_path(file_path) {
191+
#[cfg_attr(not(target_os = "windows"), allow(unused_mut))]
192+
let mut normalized = match self.normalize_path(file_path) {
184193
Some(p) => p,
185194
None => return false, // Path can't be normalized
186195
};
187196

197+
// On Windows, convert to lowercase for case-insensitive matching
198+
#[cfg(target_os = "windows")]
199+
{
200+
normalized = normalized.to_lowercase();
201+
}
202+
188203
// 1. Check files array first (absolute priority)
189204
if let Some(files) = &self.files {
190205
for file in files {

0 commit comments

Comments
 (0)