Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions codeflash/lsp/helpers.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os
import re
from functools import lru_cache
from pathlib import Path

from rich.tree import Tree

from codeflash.models.test_type import TestType

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


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