Skip to content

Commit 369e08a

Browse files
committed
fix: normalize Windows-style paths on non-Windows hosts (fixes #test regression)
normalize_file_path() only lowercased drive-letter paths on sys.platform== "win32", so on Linux/WSL paths like "d:\_Cpp_Digest\foo" and "d:\_cpp_digest\foo" normalized to different strings. This caused _determine_project_for_conversation() to miss workspace_path_to_id lookups when Cursor stored the same path in different cases across storage locations (e.g. project layout context vs workspace.json). Fix: detect Windows-style absolute paths (matching /^[a-z]:[/\\]/) and apply the same slash normalization and lowercasing on all platforms. All 137 tests now pass.
1 parent dc1af1b commit 369e08a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

utils/path_helpers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ def normalize_file_path(file_path: str) -> str:
4040
except Exception:
4141
pass
4242

43-
# Platform-specific normalization
43+
# Normalize Windows-style paths: lowercase and unify slashes.
44+
# Done unconditionally for paths that look like Windows absolute paths
45+
# (e.g. "d:\foo" or "d:/foo") so that cross-platform reads (WSL, Linux
46+
# reading Cursor's Windows storage) get the same result as native Win32.
4447
if sys.platform == "win32":
4548
normalized = normalized.replace("/", "\\")
46-
# Remove leading backslash before drive letter
4749
normalized = re.sub(r"^\\([a-zA-Z]:)", r"\1", normalized)
4850
normalized = normalized.lower()
51+
elif re.match(r"^[a-zA-Z]:[/\\]", normalized):
52+
# Windows-style absolute path on a non-Windows host.
53+
normalized = normalized.replace("/", "\\")
54+
normalized = normalized.lower()
4955

5056
return normalized
5157

0 commit comments

Comments
 (0)