Split up a change in removed lines and in added lines
This commit is contained in:
parent
4715d9d858
commit
0aee4d44a5
1 changed files with 14 additions and 0 deletions
|
|
@ -4,6 +4,20 @@ import sys
|
|||
|
||||
|
||||
def should_include_change(change_lines: list[str], search: str, replace: str) -> bool:
|
||||
removed_lines = []
|
||||
added_lines = []
|
||||
phase = "minus"
|
||||
for line in change_lines:
|
||||
if line.startswith("-"):
|
||||
if phase != "minus":
|
||||
raise ValueError("Non-consecutive '-' and '+' lines in change block.")
|
||||
removed_lines.append(line[1:])
|
||||
continue
|
||||
if line.startswith("+"):
|
||||
phase = "plus"
|
||||
added_lines.append(line[1:])
|
||||
continue
|
||||
raise ValueError("Unexpected non-change line in change block.")
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue