Finds context, handling EOF marker.
(lines: List[str], context: List[str], start: int, eof: bool)
| 79 | |
| 80 | |
| 81 | def 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 | |
| 96 | def peek_next_section(lines: List[str], index: int) -> Tuple[List[str], List[Chunk], int, bool]: |
no test coverage detected