MCPcopy Create free account
hub / github.com/experdot/pointer / findNthMatchIndex

Function findNthMatchIndex

src/renderer/src/hooks/useGlobalSearchHighlight.ts:168–183  ·  view source on GitHub ↗
(fullText: string, matchText: string, occurrenceIndex: number)

Source from the content-addressed store, hash-verified

166}
167
168function findNthMatchIndex(fullText: string, matchText: string, occurrenceIndex: number): number {
169 let currentIndex = 0
170 let searchStartIndex = 0
171
172 while (true) {
173 const idx = fullText.indexOf(matchText, searchStartIndex)
174 if (idx === -1) return -1
175
176 if (currentIndex === occurrenceIndex) {
177 return idx
178 }
179
180 currentIndex++
181 searchStartIndex = idx + 1
182 }
183}
184
185/**
186 * 根据拼接文本的偏移量创建 Range

Callers 1

applyHighlightFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected