From 379e3ce2f66bb44f173edac23c20adb47c645306 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Wed, 21 Jan 2026 08:32:22 +0800 Subject: [PATCH] feat(config): normalize paths for case-insensitive comparison on Windows, see #774 and #772 Use os.path.normcase to ensure case-insensitive path matching on Windows, addressing issues where drive letter case mismatches (e.g., 'a:/folder' vs 'A:/folder') prevented correct detection of paths under preview roots. Replace Path.relative_to() with string-based comparison for consistent behavior across platforms. --- py/config.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/py/config.py b/py/config.py index f5bb017e..548fcaef 100644 --- a/py/config.py +++ b/py/config.py @@ -665,12 +665,15 @@ class Config: except Exception: return False + # Use os.path.normcase for case-insensitive comparison on Windows. + # On Windows, Path.relative_to() is case-sensitive for drive letters, + # causing paths like 'a:/folder' to not match 'A:/folder'. + candidate_str = os.path.normcase(str(candidate)) for root in self._preview_root_paths: - try: - candidate.relative_to(root) + root_str = os.path.normcase(str(root)) + # Check if candidate is equal to or under the root directory + if candidate_str == root_str or candidate_str.startswith(root_str + os.sep): return True - except ValueError: - continue return False