Skip to content

Commit 51e218c

Browse files
committed
Revert "Revert "Fix the chat context menu removing UTF8 characters causing pure UTF8 character filenames not to display in the menu (RooCodeInc#1145)""
This reverts commit e0b90b2.
1 parent ce2610a commit 51e218c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { useExtensionState } from "../../context/ExtensionStateContext"
1616
import { findMatchingResourceOrTemplate } from "../../utils/mcp"
1717
import { vscode } from "../../utils/vscode"
1818
import { CheckpointControls, CheckpointOverlay } from "../common/CheckpointControls"
19-
import CodeAccordian, { removeLeadingNonAlphanumeric } from "../common/CodeAccordian"
19+
import CodeAccordian, { cleanPathPrefix } from "../common/CodeAccordian"
2020
import CodeBlock, { CODE_BLOCK_BG_COLOR } from "../common/CodeBlock"
2121
import MarkdownBlock from "../common/MarkdownBlock"
2222
import SuccessButton from "../common/SuccessButton"
@@ -427,7 +427,7 @@ export const ChatRowContent = ({ message, isExpanded, onToggleExpand, lastModifi
427427
direction: "rtl",
428428
textAlign: "left",
429429
}}>
430-
{removeLeadingNonAlphanumeric(tool.path ?? "") + "\u200E"}
430+
{cleanPathPrefix(tool.path ?? "") + "\u200E"}
431431
</span>
432432
<div style={{ flexGrow: 1 }}></div>
433433
<span

webview-ui/src/components/chat/ContextMenu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useMemo, useRef } from "react"
22
import { ContextMenuOptionType, ContextMenuQueryItem, getContextMenuOptions } from "../../utils/context-mentions"
3-
import { removeLeadingNonAlphanumeric } from "../common/CodeAccordian"
3+
import { cleanPathPrefix } from "../common/CodeAccordian"
44

55
interface ContextMenuProps {
66
onSelect: (type: ContextMenuOptionType, value?: string) => void
@@ -67,7 +67,7 @@ const ContextMenu: React.FC<ContextMenuProps> = ({
6767
direction: "rtl",
6868
textAlign: "left",
6969
}}>
70-
{removeLeadingNonAlphanumeric(option.value || "") + "\u200E"}
70+
{cleanPathPrefix(option.value || "") + "\u200E"}
7171
</span>
7272
</>
7373
)

webview-ui/src/components/common/CodeAccordian.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We need to remove leading non-alphanumeric characters from the path in order for
2020
[^a-zA-Z0-9]+: Matches one or more characters that are not alphanumeric.
2121
The replace method removes these matched characters, effectively trimming the string up to the first alphanumeric character.
2222
*/
23-
export const removeLeadingNonAlphanumeric = (path: string): string => path.replace(/^[^a-zA-Z0-9]+/, "")
23+
export const cleanPathPrefix = (path: string): string => path.replace(/^[^\u4e00-\u9fa5a-zA-Z0-9]+/, "")
2424

2525
const CodeAccordian = ({
2626
code,
@@ -90,7 +90,7 @@ const CodeAccordian = ({
9090
direction: "rtl",
9191
textAlign: "left",
9292
}}>
93-
{removeLeadingNonAlphanumeric(path ?? "") + "\u200E"}
93+
{cleanPathPrefix(path ?? "") + "\u200E"}
9494
</span>
9595
</>
9696
)}

0 commit comments

Comments
 (0)