File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
src/renderer/src/components/common/markdown Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -101,14 +101,13 @@ const SearchableMarkdown: React.FC<SearchableMarkdownProps> = ({
101101 let currentMatchIndexInMessage = - 1
102102 if ( currentMatch ?. messageId === messageId && allMatches . length > 0 ) {
103103 // 这个消息包含当前匹配
104- // 使用matchIndex(消息内的索引)来确定高亮哪个
105- const targetMatchIndex = currentMatch . matchIndex || 0
104+ // 使用startIndex来找到对应的匹配项
105+ const matchIndex = allMatches . findIndex ( m => m . globalStart === currentMatch . startIndex )
106106
107- // 确保索引在有效范围内
108- if ( targetMatchIndex < allMatches . length ) {
109- currentMatchIndexInMessage = targetMatchIndex
107+ if ( matchIndex !== - 1 ) {
108+ currentMatchIndexInMessage = matchIndex
110109 } else {
111- // 如果索引超出范围 ,高亮第一个
110+ // 如果找不到精确匹配 ,高亮第一个
112111 currentMatchIndexInMessage = 0
113112 }
114113 }
You can’t perform that action at this time.
0 commit comments