Skip to content

Commit e0e291e

Browse files
committed
fix(windows): use posix paths for highlights and rect_map keys
str(Path) on Windows produces backslashes, breaking highlights lookups that compare against forward-slash paths from git output. Switch to Path.as_posix() in git_scanner.py and render_png.py.
1 parent aad39d5 commit e0e291e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/dirplot/git_scanner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,17 @@ def git_apply_diff(
143143
fp = path_list[0]
144144
if fp.split("/")[0] not in exclude:
145145
to_add[fp] = new_hash
146-
highlights[str(repo / fp)] = "created"
146+
highlights[(repo / fp).as_posix()] = "created"
147147
elif status == "M" and path_list:
148148
fp = path_list[0]
149149
if fp.split("/")[0] not in exclude:
150150
to_add[fp] = new_hash
151-
highlights[str(repo / fp)] = "modified"
151+
highlights[(repo / fp).as_posix()] = "modified"
152152
elif status == "D" and path_list:
153153
fp = path_list[0]
154154
if fp.split("/")[0] not in exclude:
155155
to_delete.append(fp)
156-
highlights[str(repo / fp)] = "deleted"
156+
highlights[(repo / fp).as_posix()] = "deleted"
157157
elif status.startswith("R") and len(path_list) >= 2:
158158
old_fp, new_fp = path_list[0], path_list[1]
159159
if old_fp.split("/")[0] not in exclude:

src/dirplot/render_png.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def draw_node(
263263

264264
if not node.is_dir:
265265
if rect_map is not None:
266-
rect_map[str(node.path)] = (x, y, w, h)
266+
rect_map[node.path.as_posix()] = (x, y, w, h)
267267
rgba = color_map.get(node.extension, (0.5, 0.5, 0.5, 1.0))
268268
rgb = (int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255))
269269
draw.rectangle([x, y, x + w - 1, y + h - 1], fill=rgb)

0 commit comments

Comments
 (0)