mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
feat: Add line endings configuration option for file writing
This commit is contained in:
parent
ac26fc6d5f
commit
c3952cb985
3 changed files with 11 additions and 1 deletions
|
@ -198,6 +198,7 @@ class InputOutput:
|
|||
completion_menu_current_bg_color=None,
|
||||
code_theme="default",
|
||||
encoding="utf-8",
|
||||
line_endings="platform",
|
||||
dry_run=False,
|
||||
llm_history_file=None,
|
||||
editingmode=EditingMode.EMACS,
|
||||
|
@ -244,6 +245,8 @@ class InputOutput:
|
|||
self.chat_history_file = None
|
||||
|
||||
self.encoding = encoding
|
||||
self.newline = None if line_endings == "platform" \
|
||||
else "\n" if line_endings == "lf" else "\r\n"
|
||||
self.dry_run = dry_run
|
||||
|
||||
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
@ -375,7 +378,7 @@ class InputOutput:
|
|||
delay = initial_delay
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
with open(str(filename), "w", encoding=self.encoding) as f:
|
||||
with open(str(filename), "w", encoding=self.encoding, newline=self.newline) as f:
|
||||
f.write(content)
|
||||
return # Successfully wrote the file
|
||||
except PermissionError as err:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue