mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05:00 +00:00
regularize inputs
This commit is contained in:
parent
a6c2841342
commit
a0f03ab0ce
1 changed files with 10 additions and 3 deletions
|
@ -45,12 +45,19 @@ The ORIGINAL block needs to be EXACTLY the same as the lines in {path} with noth
|
||||||
return edited
|
return edited
|
||||||
|
|
||||||
|
|
||||||
|
def prep(content):
|
||||||
|
if not content.endswith("\n"):
|
||||||
|
content += "\n"
|
||||||
|
lines = content.splitlines(keepends=True)
|
||||||
|
return content, lines
|
||||||
|
|
||||||
|
|
||||||
def replace_most_similar_chunk(whole, part, replace):
|
def replace_most_similar_chunk(whole, part, replace):
|
||||||
"""Best efforts to find the `part` lines in `whole` and replace them with `replace`"""
|
"""Best efforts to find the `part` lines in `whole` and replace them with `replace`"""
|
||||||
|
|
||||||
whole_lines = whole.splitlines(keepends=True)
|
whole, whole_lines = prep(whole)
|
||||||
part_lines = part.splitlines(keepends=True)
|
part, part_lines = prep(part)
|
||||||
replace_lines = replace.splitlines(keepends=True)
|
replace, replace_lines = prep(replace)
|
||||||
|
|
||||||
# Try for a perfect match
|
# Try for a perfect match
|
||||||
if part_lines in whole_lines:
|
if part_lines in whole_lines:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue