refactor: Move message and style initialization before try block in InputOutput

This commit is contained in:
Paul Gauthier 2025-01-04 11:04:32 -08:00 committed by Paul Gauthier (aider)
parent cec9f90c1c
commit 48b8f54c12

View file

@ -804,9 +804,9 @@ class InputOutput:
hist = message.strip() if strip else message
self.append_chat_history(hist, linebreak=True, blockquote=True)
message = Text(message)
style = dict(style=color) if self.pretty and color else dict()
try:
message = Text(message)
style = dict(style=color) if self.pretty and color else dict()
self.console.print(message, **style)
except UnicodeEncodeError:
# Fallback to ASCII-safe output