From b3cceceac7f6fb2afd4b9668fd9ac31ce5bf8416 Mon Sep 17 00:00:00 2001
From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>
Date: Tue, 17 Sep 2024 18:21:54 -0400
Subject: [PATCH] Fix file path truncation for hidden files/folders
---
webview-ui/src/components/ChatRow.tsx | 5 +++--
webview-ui/src/components/CodeAccordian.tsx | 11 ++++++-----
webview-ui/src/components/ContextMenu.tsx | 5 +++--
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/webview-ui/src/components/ChatRow.tsx b/webview-ui/src/components/ChatRow.tsx
index 1d9cb75..e56c68c 100644
--- a/webview-ui/src/components/ChatRow.tsx
+++ b/webview-ui/src/components/ChatRow.tsx
@@ -4,7 +4,7 @@ import React, { memo, useMemo } from "react"
import ReactMarkdown from "react-markdown"
import { ClaudeMessage, ClaudeSayTool } from "../../../src/shared/ExtensionMessage"
import { COMMAND_OUTPUT_STRING } from "../../../src/shared/combineCommandSequences"
-import CodeAccordian, { removeLeadingNonAlphanumeric } from "./CodeAccordian"
+import CodeAccordian, { formatFilePathForTruncation } from "./CodeAccordian"
import CodeBlock, { CODE_BLOCK_BG_COLOR } from "./CodeBlock"
import Thumbnails from "./Thumbnails"
import { vscode } from "../utils/vscode"
@@ -228,8 +228,9 @@ const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifiedMessa
marginRight: "8px",
direction: "rtl",
textAlign: "left",
+ unicodeBidi: "plaintext",
}}>
- {removeLeadingNonAlphanumeric(tool.path ?? "") + "\u200E"}
+ {formatFilePathForTruncation(tool.path ?? "") + "\u200E"}
path.replace(/^[^a-zA-Z0-9]+/, "")
+export const formatFilePathForTruncation = (path: string): string => path.replace(/^[^a-zA-Z0-9.]+/, "")
const CodeAccordian = ({ code, diff, language, path, isFeedback, isExpanded, onToggleExpand }: CodeAccordianProps) => {
const inferredLanguage = useMemo(
@@ -73,8 +73,9 @@ const CodeAccordian = ({ code, diff, language, path, isFeedback, isExpanded, onT
// trick to get ellipsis at beginning of string
direction: "rtl",
textAlign: "left",
+ unicodeBidi: "plaintext",
}}>
- {removeLeadingNonAlphanumeric(path ?? "") + "\u200E"}
+ {formatFilePathForTruncation(path ?? "") + "\u200E"}
>
)}
diff --git a/webview-ui/src/components/ContextMenu.tsx b/webview-ui/src/components/ContextMenu.tsx
index 67db54d..8c18857 100644
--- a/webview-ui/src/components/ContextMenu.tsx
+++ b/webview-ui/src/components/ContextMenu.tsx
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from "react"
import { getContextMenuOptions } from "../utils/mention-context"
-import { removeLeadingNonAlphanumeric } from "./CodeAccordian"
+import { formatFilePathForTruncation } from "./CodeAccordian"
interface ContextMenuProps {
onSelect: (type: string, value: string) => void
@@ -79,8 +79,9 @@ const ContextMenu: React.FC = ({
textOverflow: "ellipsis",
direction: "rtl",
textAlign: "left",
+ unicodeBidi: "plaintext",
}}>
- {removeLeadingNonAlphanumeric(option.value) + "\u200E"}
+ {formatFilePathForTruncation(option.value) + "\u200E"}
)
}