mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
If all lines in the part start with whitespace, then honor it.
This commit is contained in:
parent
329baf3717
commit
5a3fd35c16
1 changed files with 6 additions and 0 deletions
|
@ -64,6 +64,12 @@ def replace_part_with_missing_leading_whitespace(whole, part, replace):
|
|||
part_lines = part.splitlines()
|
||||
replace_lines = replace.splitlines()
|
||||
|
||||
# If all lines in the part start with whitespace, then honor it.
|
||||
# But GPT often outdents the part and replace blocks completely,
|
||||
# thereby discarding the actual leading whitespace in the file.
|
||||
if all(pline[0].isspace() for pline in part_lines):
|
||||
return
|
||||
|
||||
for i in range(len(whole_lines) - len(part_lines) + 1):
|
||||
leading_whitespace = ""
|
||||
for j, c in enumerate(whole_lines[i]):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue