+
diff --git a/client/src/components/Code/CodeLine.tsx b/client/src/components/Code/CodeLine.tsx
index 980c3708ba..cdb2e5419d 100644
--- a/client/src/components/Code/CodeLine.tsx
+++ b/client/src/components/Code/CodeLine.tsx
@@ -1,4 +1,12 @@
-import React, { ReactNode, useRef, memo, useMemo, CSSProperties } from 'react';
+import React, {
+ ReactNode,
+ useRef,
+ memo,
+ useMemo,
+ CSSProperties,
+ useEffect,
+} from 'react';
+import { markNode, unmark } from '../../utils/textSearch';
type Props = {
lineNumber: number;
@@ -13,6 +21,7 @@ type Props = {
hoveredBackground?: boolean;
highlightColor?: string | null;
style?: CSSProperties;
+ searchTerm?: string;
};
const CodeLine = ({
@@ -28,8 +37,27 @@ const CodeLine = ({
highlightColor,
hoveredBackground,
style,
+ searchTerm,
}: Props) => {
const codeRef = useRef
(null);
+
+ useEffect(() => {
+ if (codeRef.current && searchTerm) {
+ markNode(
+ codeRef.current,
+ new RegExp(
+ searchTerm.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'),
+ 'gi',
+ ),
+ );
+ }
+ return () => {
+ if (codeRef.current) {
+ unmark(codeRef.current);
+ }
+ };
+ }, [searchTerm]);
+
const styleCombined = useMemo(
() => ({
...style,
diff --git a/client/src/components/SearchOnPage/index.tsx b/client/src/components/SearchOnPage/index.tsx
index a16d698822..f1a00448f5 100644
--- a/client/src/components/SearchOnPage/index.tsx
+++ b/client/src/components/SearchOnPage/index.tsx
@@ -55,14 +55,14 @@ const SearchOnPage = ({
inputClassName="pr-24"
onEscape={onCancel}
/>
-
+
{resultNum ? (
{currentResult}/{resultNum}
) : null}