mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
Handle successive editblocks from same file w/o filename #267
This commit is contained in:
parent
ebbb5bd442
commit
3299d90317
2 changed files with 34 additions and 1 deletions
|
@ -341,7 +341,7 @@ def find_original_update_blocks(content):
|
|||
try:
|
||||
if not len(filename) or "`" in filename:
|
||||
filename = processed[-2].splitlines()[-2].strip()
|
||||
if not len(filename) or "`" in filename:
|
||||
if not len(filename) or "`" in filename or filename == "...":
|
||||
if current_filename:
|
||||
filename = current_filename
|
||||
else:
|
||||
|
|
|
@ -345,6 +345,39 @@ new
|
|||
content = Path(file1).read_text(encoding="utf-8")
|
||||
self.assertEqual(content, orig_content)
|
||||
|
||||
def test_find_original_update_blocks_mupltiple_same_file(self):
|
||||
edit = """
|
||||
Here's the change:
|
||||
|
||||
```text
|
||||
foo.txt
|
||||
<<<<<<< HEAD
|
||||
one
|
||||
=======
|
||||
two
|
||||
>>>>>>> updated
|
||||
|
||||
...
|
||||
|
||||
<<<<<<< HEAD
|
||||
three
|
||||
=======
|
||||
four
|
||||
>>>>>>> updated
|
||||
```
|
||||
|
||||
Hope you like it!
|
||||
"""
|
||||
|
||||
edits = list(eb.find_original_update_blocks(edit))
|
||||
self.assertEqual(
|
||||
edits,
|
||||
[
|
||||
("foo.txt", "one\n", "two\n"),
|
||||
("foo.txt", "three\n", "four\n"),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue