Skip to content

Commit 6a44709

Browse files
fix: improve worktree path handling for cross-platform compatibility
1 parent 4157d47 commit 6a44709

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

codeflash/lsp/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
_double_quote_pat = re.compile(r'"(.*?)"')
1010
_single_quote_pat = re.compile(r"'(.*?)'")
11-
worktree_path_regex = re.compile(r'\/[^"]*worktrees\/[^"]\S*')
11+
# Match worktree paths on both Unix (/path/to/worktrees/...) and Windows (C:\path\to\worktrees\... or C:/path/to/worktrees/...)
12+
worktree_path_regex = re.compile(r'[^"]*worktrees[\\/][^"]\S*')
1213

1314

1415
@lru_cache(maxsize=1)
@@ -47,7 +48,8 @@ def report_to_markdown_table(report: dict[TestType, dict[str, int]], title: str)
4748
def simplify_worktree_paths(msg: str, highlight: bool = True) -> str: # noqa: FBT001, FBT002
4849
path_in_msg = worktree_path_regex.search(msg)
4950
if path_in_msg:
50-
last_part_of_path = path_in_msg.group(0).split("/")[-1]
51+
# Use os.path.basename to handle both Unix and Windows path separators
52+
last_part_of_path = os.path.basename(path_in_msg.group(0))
5153
if highlight:
5254
last_part_of_path = f"`{last_part_of_path}`"
5355
return msg.replace(path_in_msg.group(0), last_part_of_path)

0 commit comments

Comments
 (0)