Skip to content

Commit

Permalink
fix: add error handling for clipboard operations in copy_context command
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-gauthier committed Dec 11, 2024
1 parent b7984a0 commit 730e5bd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions aider/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,8 +1447,16 @@ def cmd_copy_context(self, args=None):
"""

pyperclip.copy(markdown)
self.io.tool_output("Copied code context to clipboard.")
try:
pyperclip.copy(markdown)
self.io.tool_output("Copied code context to clipboard.")
except pyperclip.PyperclipException as e:
self.io.tool_error(f"Failed to copy to clipboard: {str(e)}")
self.io.tool_output(
"You may need to install xclip or xsel on Linux, or pbcopy on macOS."
)
except Exception as e:
self.io.tool_error(f"An unexpected error occurred while copying to clipboard: {str(e)}")


def expand_subdir(file_path):
Expand Down

0 comments on commit 730e5bd

Please sign in to comment.