diff --git a/src/utils/formatUtil.ts b/src/utils/formatUtil.ts index 7b7966394..da933d3ec 100644 --- a/src/utils/formatUtil.ts +++ b/src/utils/formatUtil.ts @@ -39,7 +39,11 @@ export function trimJsonExt(path?: string) { export function highlightQuery(text: string, query: string) { if (!query) return text - const regex = new RegExp(`(${query})`, 'gi') + + // Escape special regex characters in the query string + const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + + const regex = new RegExp(`(${escapedQuery})`, 'gi') return text.replace(regex, '$1') }