Refactor: Rename file search functions for clarity
This commit is contained in:
parent
c2dfb48e22
commit
250a0e1bde
@ -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<ChatRef, ChatProps>((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<ChatRef, ChatProps>((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 {
|
||||
|
||||
@ -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<string> {
|
||||
|
||||
@ -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<string> {
|
||||
|
||||
@ -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<string> {
|
||||
const regexQuery = `/${regex}/`;
|
||||
return searchFilesWithCorePlugin(regexQuery, app);
|
||||
return matchSearchUsingCorePlugin(regexQuery, app);
|
||||
}
|
||||
@ -66,7 +66,7 @@ async function execRipgrep(bin: string, args: string[]): Promise<string> {
|
||||
})
|
||||
}
|
||||
|
||||
export async function regexSearchFilesWithRipgrep(
|
||||
export async function regexSearchUsingRipgrep(
|
||||
directoryPath: string,
|
||||
regex: string,
|
||||
ripgrepPath: string,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user