Fix file path leading ellipsis

This commit is contained in:
Saoud Rizwan
2024-09-19 17:52:25 -04:00
parent 5fbb335bb6
commit 9351b4b633
3 changed files with 28 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useRef } from "react"
import { ContextMenuOptionType, ContextMenuQueryItem, getContextMenuOptions } from "../utils/context-mentions"
import { formatFilePathForTruncation } from "./CodeAccordian"
import { removeLeadingNonAlphanumeric } from "./CodeAccordian"
interface ContextMenuProps {
onSelect: (type: ContextMenuOptionType, value?: string) => void
@@ -56,17 +56,20 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
case ContextMenuOptionType.Folder:
if (option.value) {
return (
<span
style={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
direction: "rtl",
textAlign: "left",
unicodeBidi: "plaintext",
}}>
{formatFilePathForTruncation(option.value || "") + "\u200E"}
</span>
<>
<span>/</span>
{option.value?.startsWith("/.") && <span>.</span>}
<span
style={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
direction: "rtl",
textAlign: "left",
}}>
{removeLeadingNonAlphanumeric(option.value || "") + "\u200E"}
</span>
</>
)
} else {
return <span>Add {option.type === ContextMenuOptionType.File ? "File" : "Folder"}</span>