aider: Added a check to ensure that part appears in whole exactly once in try_dotdotdots.

# Context:
USER: in try_dotdotdots, after checking that part is in whole add a check that part is in whole exactly 1 time
ASSISTANT: ```python
aider/utils.py
<<<<<<< ORIGINAL
        if part not in whole:
            raise ValueError("No perfect matching chunk in edit block with ...")

        whole = whole.replace(part, replace)
=======
        if whole.count(part) != 1:
            raise ValueError("No perfect matching chunk in edit block with ... or part appears more than once")

        whole = whole.replace(part, replace, 1)
>>>>>>> UPDATED
```
This commit is contained in:
Paul Gauthier 2023-05-17 16:15:09 -07:00
parent de69a3095a
commit cc0ee034f4

View file

@ -50,10 +50,10 @@ def try_dotdotdots(whole, part, replace):
whole += replace
continue
if part not in whole:
raise ValueError("No perfect matching chunk in edit block with ...")
if whole.count(part) != 1:
raise ValueError("No perfect matching chunk in edit block with ... or part appears more than once")
whole = whole.replace(part, replace)
whole = whole.replace(part, replace, 1)
return whole