Last-resort split: cut at line boundaries to fit budget.
(start_line: int, block_text: str)
| 231 | return "\n".join(numbered) |
| 232 | |
| 233 | def _split_by_lines(start_line: int, block_text: str) -> list[tuple[int, str]]: |
| 234 | """Last-resort split: cut at line boundaries to fit budget.""" |
| 235 | lines = block_text.split("\n") |
| 236 | result: list[tuple[int, str]] = [] |
| 237 | cur_lines: list[str] = [] |
| 238 | cur_start = start_line |
| 239 | for line in lines: |
| 240 | candidate = "\n".join(cur_lines + [line]) |
| 241 | if len(_number_block(cur_start, candidate)) > budget and cur_lines: |
| 242 | result.append((cur_start, "\n".join(cur_lines))) |
| 243 | cur_start += len(cur_lines) |
| 244 | cur_lines = [] |
| 245 | cur_lines.append(line) |
| 246 | if cur_lines: |
| 247 | result.append((cur_start, "\n".join(cur_lines))) |
| 248 | return result |
| 249 | |
| 250 | blocks: list[tuple[int, str]] = [] |
| 251 | for start_line, section_text in sections: |
no test coverage detected