From c3e08a80eb9e21b73a4b59a556504c24228c1c9a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 9 Aug 2024 17:27:58 -0400 Subject: [PATCH] fix: Add paginate option to cmd_diff method --- aider/commands.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 79f47a677..ca8a551fe 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -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: