mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-27 07:38:51 +00:00
fix(app): probe a Find seek in the match's own part
A seek now probes on every one of its 12 frames. Each probe read the text of every mounted row to find one match, which cost 35% to 39% more main-thread work in the find in session bench.
This commit is contained in:
parent
371ef6d2b2
commit
e784335e71
1 changed files with 9 additions and 1 deletions
|
|
@ -93,6 +93,14 @@ function collectRanges(
|
|||
return { hits, active }
|
||||
}
|
||||
|
||||
// The active match alone. A seek probes on every one of its frames, so the probe reads the match's own part and not
|
||||
// the text of every mounted row.
|
||||
function activeRange(root: HTMLElement, query: string, partID: string, occurrence: number) {
|
||||
const part = root.querySelector<HTMLElement>(`[data-timeline-part-id="${CSS.escape(partID)}"]`)
|
||||
|
||||
return part ? collectRanges(part, query, partID, occurrence).active[0] : undefined
|
||||
}
|
||||
|
||||
function applyHighlights(
|
||||
root: HTMLElement,
|
||||
query: string,
|
||||
|
|
@ -285,7 +293,7 @@ export function createTranscriptSearch(
|
|||
const root = input.scrollRef()
|
||||
|
||||
if (!root) return { type: "seek.missing", attempt: effect.attempt }
|
||||
const range = collectRanges(root, effect.query, effect.partID, effect.occurrence).active[0]
|
||||
const range = activeRange(root, effect.query, effect.partID, effect.occurrence)
|
||||
|
||||
if (!range) return { type: "seek.missing", attempt: effect.attempt }
|
||||
const rect = range.getBoundingClientRect()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue