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

Function countOccurrencesBefore

src/renderer/src/utils/globalSearchUtils.ts:128–140  ·  view source on GitHub ↗
(content: string, matchText: string, currentOffset: number)

Source from the content-addressed store, hash-verified

126}
127
128function countOccurrencesBefore(content: string, matchText: string, currentOffset: number): number {
129 let count = 0
130 let searchIndex = 0
131
132 while (searchIndex < currentOffset) {
133 const idx = content.indexOf(matchText, searchIndex)
134 if (idx === -1 || idx >= currentOffset) break
135 count++
136 searchIndex = idx + 1
137 }
138
139 return count
140}
141
142/**
143 * 在单个页面的消息中搜索,返回按消息分组的结果

Callers 1

searchInMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected