Skip to content

Commit 524c0d3

Browse files
Merge pull request #1035 from codeflash-ai/fix/worktree-path-highlighted-windows
fix: improve worktree path handling for cross-platform compatibility
2 parents 4157d47 + 3f4e0e1 commit 524c0d3

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

codeflash/lsp/helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import os
22
import re
33
from functools import lru_cache
4+
from pathlib import Path
45

56
from rich.tree import Tree
67

78
from codeflash.models.test_type import TestType
89

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

1315

1416
@lru_cache(maxsize=1)
@@ -47,7 +49,8 @@ def report_to_markdown_table(report: dict[TestType, dict[str, int]], title: str)
4749
def simplify_worktree_paths(msg: str, highlight: bool = True) -> str: # noqa: FBT001, FBT002
4850
path_in_msg = worktree_path_regex.search(msg)
4951
if path_in_msg:
50-
last_part_of_path = path_in_msg.group(0).split("/")[-1]
52+
# Use Path.name to handle both Unix and Windows path separators
53+
last_part_of_path = Path(path_in_msg.group(0)).name
5154
if highlight:
5255
last_part_of_path = f"`{last_part_of_path}`"
5356
return msg.replace(path_in_msg.group(0), last_part_of_path)

0 commit comments

Comments
 (0)