diff --git a/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatch.tsx b/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatch.tsx
index a24b8e45..3b1943ba 100644
--- a/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatch.tsx
+++ b/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatch.tsx
@@ -1,27 +1,22 @@
'use client';
-import { useCallback } from "react";
import { SearchResultFile, SearchResultChunk } from "@/features/search/types";
import { LightweightCodeHighlighter } from "@/app/[domain]/components/lightweightCodeHighlighter";
+import Link from "next/link";
+import { getBrowsePath } from "@/app/[domain]/browse/hooks/useBrowseNavigation";
+import { useDomain } from "@/hooks/useDomain";
interface FileMatchProps {
match: SearchResultChunk;
file: SearchResultFile;
- onOpen: (startLineNumber: number, endLineNumber: number, isCtrlKeyPressed: boolean) => void;
}
export const FileMatch = ({
match,
file,
- onOpen: _onOpen,
}: FileMatchProps) => {
- const onOpen = useCallback((isCtrlKeyPressed: boolean) => {
- const startLineNumber = match.contentStart.lineNumber;
- const endLineNumber = match.content.trimEnd().split('\n').length + startLineNumber - 1;
-
- _onOpen(startLineNumber, endLineNumber, isCtrlKeyPressed);
- }, [match.content, match.contentStart.lineNumber, _onOpen]);
+ const domain = useDomain();
// If it's just the title, don't show a code preview
if (match.matchRanges.length === 0) {
@@ -29,19 +24,24 @@ export const FileMatch = ({
}
return (
-
{
- if (e.key !== "Enter") {
- return;
+ href={getBrowsePath({
+ repoName: file.repository,
+ revisionName: file.branches?.[0] ?? 'HEAD',
+ path: file.fileName.text,
+ pathType: 'blob',
+ domain,
+ highlightRange: {
+ start: {
+ lineNumber: match.contentStart.lineNumber,
+ },
+ end: {
+ lineNumber: match.content.trimEnd().split('\n').length + match.contentStart.lineNumber - 1,
+ }
}
-
- onOpen(e.metaKey || e.ctrlKey);
- }}
- onClick={(e) => {
- onOpen(e.metaKey || e.ctrlKey);
- }}
+ })}
title="open file: click, open file preview: cmd/ctrl + click"
>
{match.content}
-
+
);
}
\ No newline at end of file
diff --git a/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatchContainer.tsx b/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatchContainer.tsx
index 820521b9..b10d656a 100644
--- a/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatchContainer.tsx
+++ b/packages/web/src/app/[domain]/search/components/searchResultsPanel/fileMatchContainer.tsx
@@ -7,7 +7,6 @@ import { useMemo } from "react";
import { FileMatch } from "./fileMatch";
import { RepositoryInfo, SearchResultFile } from "@/features/search/types";
import { Button } from "@/components/ui/button";
-import { useBrowseNavigation } from "@/app/[domain]/browse/hooks/useBrowseNavigation";
export const MAX_MATCHES_TO_PREVIEW = 3;
@@ -33,7 +32,6 @@ export const FileMatchContainer = ({
const matchCount = useMemo(() => {
return file.chunks.length;
}, [file]);
- const { navigateToPath } = useBrowseNavigation();
const matches = useMemo(() => {
const sortedMatches = file.chunks.sort((a, b) => {
@@ -123,29 +121,6 @@ export const FileMatchContainer = ({
{
- if (isCtrlKeyPressed) {
- const matchIndex = matches.slice(0, index).reduce((acc, match) => {
- return acc + match.matchRanges.length;
- }, 0);
- onOpenFilePreview(matchIndex);
- } else {
- navigateToPath({
- repoName: file.repository,
- revisionName: file.branches?.[0] ?? 'HEAD',
- path: file.fileName.text,
- pathType: 'blob',
- highlightRange: {
- start: {
- lineNumber: startLineNumber,
- },
- end: {
- lineNumber: endLineNumber,
- }
- }
- });
- }
- }}
/>
{(index !== matches.length - 1 || isMoreContentButtonVisible) && (