Skip to content

scope

scope

reconstruct_pre

reconstruct_pre(evt: BaseHookEvent, source: str) -> str

Best-effort pre-edit source: an Edit's new_string swapped back to old_string.

Returns "" when there is nothing to diff against (a Write, or an Edit whose fragment can't be located) — the conservative choice that treats the whole file as changed.

changed_lines

changed_lines(pre: str, source: str) -> set[int]

1-based line numbers in source that differ from pre.

An empty pre means "everything changed" (a Write or an unlocatable Edit), so every line of source is returned.