MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / advanceCursorToAnchor

Function advanceCursorToAnchor

sdk/src/tools/apply-patch.ts:144–177  ·  view source on GitHub ↗
(
  anchor: string,
  inputLines: string[],
  cursor: number,
  parser: ParserState,
)

Source from the content-addressed store, hash-verified

142}
143
144function advanceCursorToAnchor(
145 anchor: string,
146 inputLines: string[],
147 cursor: number,
148 parser: ParserState,
149): number {
150 let found = false
151
152 if (!inputLines.slice(0, cursor).some((line) => line === anchor)) {
153 for (let i = cursor; i < inputLines.length; i += 1) {
154 if (inputLines[i] === anchor) {
155 cursor = i + 1
156 found = true
157 break
158 }
159 }
160 }
161
162 if (
163 !found &&
164 !inputLines.slice(0, cursor).some((line) => line.trim() === anchor.trim())
165 ) {
166 for (let i = cursor; i < inputLines.length; i += 1) {
167 if (inputLines[i]?.trim() === anchor.trim()) {
168 cursor = i + 1
169 parser.fuzz += 1
170 found = true
171 break
172 }
173 }
174 }
175
176 return cursor
177}
178
179function readSection(
180 lines: string[],

Callers 1

parseUpdateDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected