| 279 | |
| 280 | |
| 281 | def _find_context(lines: list[str], context: list[str], start: int, eof: bool) -> ContextMatch: |
| 282 | if eof: |
| 283 | end_start = max(0, len(lines) - len(context)) |
| 284 | end_match = _find_context_core(lines, context, end_start) |
| 285 | if end_match.new_index != -1: |
| 286 | return end_match |
| 287 | fallback = _find_context_core(lines, context, start) |
| 288 | return ContextMatch(new_index=fallback.new_index, fuzz=fallback.fuzz + 10000) |
| 289 | return _find_context_core(lines, context, start) |
| 290 | |
| 291 | |
| 292 | def _find_context_core(lines: list[str], context: list[str], start: int) -> ContextMatch: |