-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define edit block dividers as constants to simplify experimentation #1817
base: main
Are you sure you want to change the base?
Conversation
The flexibility is needed for aider to work with the o1 models. They don't conform to the edit format and return variable numbers of the prefix characters. |
aa12f5b
to
3da8b4c
Compare
Ok, I understand. But I believe there's a bug which makes the regex built from
but also lines with any number of equal signs, e.g. here: This is a long reStructuredText heading with way more than nine equal signs
=========================================================================== or, as a matter of fact, lines with any trailing junk (like This is due to DIVIDER = r"={5,9}"
divider_pattern = re.compile(DIVIDER) and subsequent divider_pattern.match(lines[i].strip()) only checking that the beginning of the line matches (in So what happes is: >>> lines = [
... "This is a long reStructuredText heading with way more than nine equal signs\n",
... "===========================================================================\n",
... ]
>>> re.compile(r"={5,9}").match(lines[1].strip())
<re.Match object; span=(0, 9), match='========='> This is the reason for #1803, and the easy fix is: divider_pattern = re.compile(fr"{DIVIDER}[ ]*$") although that will still cause problems with reStructuredText files which have 5-to-9-character titles. Thus, I experimented (successfully) with pseudo-XML separators (see #1803 comment), although something like |
I will apply the fix so that it doesn't match |
That change is in the main branch now. |
3da8b4c
to
3788d85
Compare
This stlil doesn't make the dividers (
<<<<<<< SEARCH
,=======
, and>>>>>>> REPLACE
) user configurable, but at least it's now more straightforward to try out and evaluate different divider strings in this branch.The patch in this PR should make it easier to fix:
Note that regular expression matchers are now the exact divider strings instead of the old
Maybe we could have them configured separately as well.