MCPcopy Index your code
hub / github.com/idank/explainshell / _split_by_lines

Function _split_by_lines

explainshell/extraction/llm/text.py:233–248  ·  view source on GitHub ↗

Last-resort split: cut at line boundaries to fit budget.

(start_line: int, block_text: str)

Source from the content-addressed store, hash-verified

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:

Callers 1

chunk_textFunction · 0.85

Calls 1

_number_blockFunction · 0.85

Tested by

no test coverage detected