Skip to main content

Function: findSnippetMatch()

function findSnippetMatch(
file,
targetHashOrResult,
originalLine,
options): Promise<number | null>;

Defined in: packages/uimatch-selector-anchors/src/hashing/snippet-hash.ts:284

Find the best matching location for a snippet in a file

This is useful when code has moved but the snippet hash doesn't match exactly due to minor changes.

Uses exponential skip search (±1,2,4,8,...) for O(log R) coarse search, then refines near best candidates for optimal performance.

Parameters

file

string

Path to source file

targetHashOrResult

Expected snippet hash string OR full SnippetHashResult with original snippet

string | SnippetHashResult

originalLine

number

Original line number where snippet was found

options

SnippetHashOptions = {}

Configuration options

Returns

Promise<number | null>

New line number if found, or null if no good match