Improve global search: Add diffing from results with query highlighting
Users can now open a diff for a specific search hit directly from the global search results. The original search query will be highlighted within the diff view, making it easier to locate the relevant changes. Additionally, add `--no-textconv` to git commands used in search and diff operations. This prevents failures when git encounters binary files that textconv drivers might otherwise attempt to process.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { CalendarDays, FileCode, LoaderCircle, Search, User, X } from "@lucide/svelte";
|
||||
import { CalendarDays, FileCode, GitCompare, LoaderCircle, Search, User, X } from "@lucide/svelte";
|
||||
import type { GitSearchHit } from "../types";
|
||||
|
||||
interface Props {
|
||||
@@ -11,6 +11,7 @@
|
||||
onClose: () => void;
|
||||
onSearch: (query: string, caseSensitive: boolean, limit: number) => void | Promise<void>;
|
||||
onCancel: () => void | Promise<void>;
|
||||
onDiff: (hit: GitSearchHit) => void | Promise<void>;
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -22,6 +23,7 @@
|
||||
onClose = () => {},
|
||||
onSearch = () => {},
|
||||
onCancel = () => {},
|
||||
onDiff = () => {},
|
||||
}: Props = $props();
|
||||
|
||||
let query = $state("");
|
||||
@@ -148,6 +150,16 @@
|
||||
{#if hit.matches_added > 1}
|
||||
<span class="pill pill-active">+{hit.matches_added} matches</span>
|
||||
{/if}
|
||||
<button
|
||||
class="btn-secondary search-hit-diff"
|
||||
type="button"
|
||||
disabled={isBusy}
|
||||
title={`Compare this version of ${hit.file} with the current version`}
|
||||
onclick={() => onDiff(hit)}
|
||||
>
|
||||
<GitCompare size={14} aria-hidden="true" />
|
||||
DIFF
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="search-hit-meta">
|
||||
|
||||
Reference in New Issue
Block a user