From d7278d367e960e3f4f7b6506c1d9e69a12e5228f Mon Sep 17 00:00:00 2001 From: aheizi Date: Sat, 29 Mar 2025 12:09:28 +0800 Subject: [PATCH] Fix mention file name is not fully displayed (#2026) Fixed path leading character handling to preserve language characters and remove specific punctuation marks --- webview-ui/src/components/common/CodeAccordian.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/webview-ui/src/components/common/CodeAccordian.tsx b/webview-ui/src/components/common/CodeAccordian.tsx index 9d2f224ffb..468eade72f 100644 --- a/webview-ui/src/components/common/CodeAccordian.tsx +++ b/webview-ui/src/components/common/CodeAccordian.tsx @@ -17,12 +17,15 @@ interface CodeAccordianProps { } /* -We need to remove leading non-alphanumeric characters from the path in order for our leading ellipses trick to work. -^: Anchors the match to the start of the string. -[^a-zA-Z0-9]+: Matches one or more characters that are not alphanumeric. -The replace method removes these matched characters, effectively trimming the string up to the first alphanumeric character. +We need to remove certain leading characters from the path in order for our leading ellipses trick to work. +However, we want to preserve all language characters (including CJK, Cyrillic, etc.) and only remove specific +punctuation that might interfere with the ellipsis display. */ -export const removeLeadingNonAlphanumeric = (path: string): string => path.replace(/^[^a-zA-Z0-9]+/, "") +export const removeLeadingNonAlphanumeric = (path: string): string => { + // Only remove specific punctuation characters that might interfere with ellipsis display + // Keep all language characters (including CJK, Cyrillic, etc.) and numbers + return path.replace(/^[/\\:*?"<>|]+/, "") +} const CodeAccordian = ({ code,