MCPcopy
hub / github.com/Aider-AI/aider / find_context

Function find_context

aider/coders/patch_coder.py:81–93  ·  view source on GitHub ↗

Finds context, handling EOF marker.

(lines: List[str], context: List[str], start: int, eof: bool)

Source from the content-addressed store, hash-verified

79
80
81def find_context(lines: List[str], context: List[str], start: int, eof: bool) -> Tuple[int, int]:
82 """Finds context, handling EOF marker."""
83 if eof:
84 # If EOF marker, first try matching at the very end
85 if len(lines) >= len(context):
86 new_index, fuzz = find_context_core(lines, context, len(lines) - len(context))
87 if new_index != -1:
88 return new_index, fuzz
89 # If not found at end, search from `start` as fallback
90 new_index, fuzz = find_context_core(lines, context, start)
91 return new_index, fuzz + 10_000 # Add large fuzz penalty if EOF wasn't at end
92 # Normal case: search from `start`
93 return find_context_core(lines, context, start)
94
95
96def peek_next_section(lines: List[str], index: int) -> Tuple[List[str], List[Chunk], int, bool]:

Callers 1

Calls 1

find_context_coreFunction · 0.85

Tested by

no test coverage detected