From 250a0e1bde46f0ab0df80a5ab5e4b648d5969e76 Mon Sep 17 00:00:00 2001 From: travertexg Date: Mon, 9 Jun 2025 16:52:36 +0000 Subject: [PATCH] Refactor: Rename file search functions for clarity --- src/components/chat-view/ChatView.tsx | 16 ++++++++-------- src/core/search/match/coreplugin-match.ts | 2 +- src/core/search/match/omnisearch-match.ts | 2 +- src/core/search/regex/coreplugin-regex.ts | 6 +++--- src/core/search/regex/ripgrep-regex.ts | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/chat-view/ChatView.tsx b/src/components/chat-view/ChatView.tsx index a477843..d236812 100644 --- a/src/components/chat-view/ChatView.tsx +++ b/src/components/chat-view/ChatView.tsx @@ -29,10 +29,10 @@ import { LLMBaseUrlNotSetException, LLMModelNotSetException, } from '../../core/llm/exception' -import { searchFilesWithCorePlugin } from '../../core/search/match/coreplugin-match' -import { searchFilesWithOmnisearch } from '../../core/search/match/omnisearch-match' -import { regexSearchFilesWithRipgrep } from '../../core/search/regex/ripgrep-regex' -import { regexSearchFilesWithCorePlugin } from '../../core/search/regex/coreplugin-regex' +import { matchSearchUsingCorePlugin } from '../../core/search/match/coreplugin-match' +import { matchSearchUsingOmnisearch } from '../../core/search/match/omnisearch-match' +import { regexSearchUsingRipgrep } from '../../core/search/regex/ripgrep-regex' +import { regexSearchUsingCorePlugin } from '../../core/search/regex/coreplugin-regex' import { useChatHistory } from '../../hooks/use-chat-history' import { useCustomModes } from '../../hooks/use-custom-mode' import { t } from '../../lang/helpers' @@ -614,9 +614,9 @@ const Chat = forwardRef((props, ref) => { const searchBackend = settings.matchSearchBackend let results: string; if (searchBackend === 'omnisearch') { - results = await searchFilesWithOmnisearch(toolArgs.query, app) + results = await matchSearchUsingOmnisearch(toolArgs.query, app) } else { - results = await searchFilesWithCorePlugin(toolArgs.query, app) + results = await matchSearchUsingCorePlugin(toolArgs.query, app) } const formattedContent = `[match_search_files for '${toolArgs.filepath}'] Result:\n${results}\n`; return { @@ -636,13 +636,13 @@ const Chat = forwardRef((props, ref) => { const searchBackend = settings.regexSearchBackend let results: string; if (searchBackend === 'coreplugin') { - results = await regexSearchFilesWithCorePlugin(toolArgs.regex, app) + results = await regexSearchUsingCorePlugin(toolArgs.regex, app) } else { // @ts-expect-error Obsidian API type mismatch const baseVaultPath = String(app.vault.adapter.getBasePath()) const absolutePath = path.join(baseVaultPath, toolArgs.filepath) const ripgrepPath = settings.ripgrepPath - results = await regexSearchFilesWithRipgrep(absolutePath, toolArgs.regex, ripgrepPath) + results = await regexSearchUsingRipgrep(absolutePath, toolArgs.regex, ripgrepPath) } const formattedContent = `[regex_search_files for '${toolArgs.filepath}'] Result:\n${results}\n`; return { diff --git a/src/core/search/match/coreplugin-match.ts b/src/core/search/match/coreplugin-match.ts index b5aaf29..c58b5b2 100644 --- a/src/core/search/match/coreplugin-match.ts +++ b/src/core/search/match/coreplugin-match.ts @@ -14,7 +14,7 @@ import { * @param query The query to search for. * @returns A promise that resolves to a formatted string of search results. */ -export async function searchFilesWithCorePlugin( +export async function matchSearchUsingCorePlugin( query: string, app: App, ): Promise { diff --git a/src/core/search/match/omnisearch-match.ts b/src/core/search/match/omnisearch-match.ts index 03f39b7..7865600 100644 --- a/src/core/search/match/omnisearch-match.ts +++ b/src/core/search/match/omnisearch-match.ts @@ -47,7 +47,7 @@ function isOmnisearchAvailable(): boolean { * @param app The Obsidian App instance. * @returns A formatted string of search results. */ -export async function searchFilesWithOmnisearch( +export async function matchSearchUsingOmnisearch( query: string, app: App, ): Promise { diff --git a/src/core/search/regex/coreplugin-regex.ts b/src/core/search/regex/coreplugin-regex.ts index 4e233f8..3c52acc 100644 --- a/src/core/search/regex/coreplugin-regex.ts +++ b/src/core/search/regex/coreplugin-regex.ts @@ -1,5 +1,5 @@ import { App } from "obsidian"; -import { searchFilesWithCorePlugin } from '../match/coreplugin-match' +import { matchSearchUsingCorePlugin } from '../match/coreplugin-match' /** * Performs a regular expression search using Obsidian's core search plugin. @@ -8,10 +8,10 @@ import { searchFilesWithCorePlugin } from '../match/coreplugin-match' * @param regex The regular expression to search for. * @returns A promise that resolves to a formatted string of search results. */ -export async function regexSearchFilesWithCorePlugin( +export async function regexSearchUsingCorePlugin( regex: string, app: App, ): Promise { const regexQuery = `/${regex}/`; - return searchFilesWithCorePlugin(regexQuery, app); + return matchSearchUsingCorePlugin(regexQuery, app); } \ No newline at end of file diff --git a/src/core/search/regex/ripgrep-regex.ts b/src/core/search/regex/ripgrep-regex.ts index 3adf6c7..0974164 100644 --- a/src/core/search/regex/ripgrep-regex.ts +++ b/src/core/search/regex/ripgrep-regex.ts @@ -66,7 +66,7 @@ async function execRipgrep(bin: string, args: string[]): Promise { }) } -export async function regexSearchFilesWithRipgrep( +export async function regexSearchUsingRipgrep( directoryPath: string, regex: string, ripgrepPath: string,