fix: Add paginate option to cmd_diff method

This commit is contained in:
Paul Gauthier 2024-08-09 17:27:58 -04:00 committed by Paul Gauthier (aider)
parent 566ac8d641
commit c3e08a80eb

View file

@ -467,7 +467,7 @@ class Commands:
if self.coder.main_model.send_undo_reply:
return prompts.undo_command_reply
def cmd_diff(self, args=""):
def cmd_diff(self, args="", paginate=False):
"Display the diff of the last aider commit"
if not self.coder.repo:
self.io.tool_error("No git repository found.")
@ -486,8 +486,15 @@ class Commands:
"HEAD",
)
# don't use io.tool_output() because we don't want to log or further colorize
print(diff)
if paginate:
# Use pypager to show the content
source = StringSource(diff)
pager = Pager()
pager.add_source(source)
pager.run()
else:
# don't use io.tool_output() because we don't want to log or further colorize
print(diff)
def quote_fname(self, fname):
if " " in fname and '"' not in fname: