@@ -15,25 +15,42 @@ import { RepositoryInfo, SearchResultFile, SearchStats } from "@/features/search
1515import useCaptureEvent from "@/hooks/useCaptureEvent" ;
1616import { useNonEmptyQueryParam } from "@/hooks/useNonEmptyQueryParam" ;
1717import { useSearchHistory } from "@/hooks/useSearchHistory" ;
18+ import { getCodeParserByLanguageName } from "@/lib/codeHighlight" ;
1819import { ServiceErrorException } from "@/lib/serviceError" ;
1920import { SearchQueryParams } from "@/lib/types" ;
2021import { createPathWithQueryParams } from "@/lib/utils" ;
2122import { InfoCircledIcon } from "@radix-ui/react-icons" ;
2223import { useLocalStorage } from "@uidotdev/usehooks" ;
2324import { AlertTriangleIcon , BugIcon , FilterIcon , RefreshCwIcon } from "lucide-react" ;
24- import { Session } from "next-auth " ;
25+ import dynamic from "next/dynamic " ;
2526import { useRouter } from "next/navigation" ;
2627import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
2728import { useHotkeys } from "react-hotkeys-hook" ;
2829import { ImperativePanelHandle } from "react-resizable-panels" ;
2930import { CopyIconButton } from "../../components/copyIconButton" ;
3031import { SearchBar } from "../../components/searchBar" ;
3132import { useStreamedSearch } from "../useStreamedSearch" ;
32- import { CodePreviewPanel } from "./codePreviewPanel" ;
3333import { FilterPanel } from "./filterPanel" ;
3434import { useFilteredMatches } from "./filterPanel/useFilterMatches" ;
3535import { SearchResultsPanel , SearchResultsPanelHandle } from "./searchResultsPanel" ;
3636
37+ const CodePreviewPanel = dynamic (
38+ ( ) => import ( "./codePreviewPanel" ) . then ( module => ( { default : module . CodePreviewPanel } ) ) ,
39+ { ssr : false } ,
40+ ) ;
41+
42+ const commonSearchResultLanguages = [
43+ "TypeScript" ,
44+ "JavaScript" ,
45+ "Python" ,
46+ "Go" ,
47+ "Rust" ,
48+ "Java" ,
49+ "C++" ,
50+ "C#" ,
51+ "JSON" ,
52+ ] ;
53+
3754interface SearchResultsPageProps {
3855 searchQuery : string ;
3956 defaultMaxMatchCount : number ;
@@ -54,6 +71,12 @@ export const SearchResultsPage = ({
5471 const { toast } = useToast ( ) ;
5572 const captureEvent = useCaptureEvent ( ) ;
5673
74+ useEffect ( ( ) => {
75+ void Promise . allSettled (
76+ commonSearchResultLanguages . map ( getCodeParserByLanguageName ) ,
77+ ) ;
78+ } , [ ] ) ;
79+
5780 // Encodes the number of matches to return in the search response.
5881 const _maxMatchCount = parseInt ( useNonEmptyQueryParam ( SearchQueryParams . matches ) ?? `${ defaultMaxMatchCount } ` ) ;
5982 const maxMatchCount = isNaN ( _maxMatchCount ) ? defaultMaxMatchCount : _maxMatchCount ;
0 commit comments