Skip to content

Commit 2e80956

Browse files
divyansshhhDivyansh Choudhary
andauthored
Fix code output format in IPython (#1155)
In an IPython terminal, using `code` format doesn't copy the code to the output cell but this works in a JupyterLab cell. Removing the payload_manager and using the `set_next_input` method directly fixes this behavior in IPython while maintaining the functionality in JupyterLab Co-authored-by: Divyansh Choudhary <choudhdi@deshaw.com>
1 parent ad0ebee commit 2e80956

File tree

1 file changed

+1
-7
lines changed
  • packages/jupyter-ai-magics/jupyter_ai_magics

1 file changed

+1
-7
lines changed

packages/jupyter-ai-magics/jupyter_ai_magics/magics.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,7 @@ def display_output(self, output, display_format, md):
482482
lang_indicator = r"^```[a-zA-Z0-9]*\n"
483483
output = re.sub(lang_indicator, "", output)
484484
output = re.sub(r"\n```$", "", output)
485-
new_cell_payload = dict(
486-
source="set_next_input",
487-
text=output,
488-
replace=False,
489-
)
490-
ip = self.shell
491-
ip.payload_manager.write_payload(new_cell_payload)
485+
self.shell.set_next_input(output, replace=False)
492486
return HTML(
493487
"AI generated code inserted below &#11015;&#65039;", metadata=md
494488
)

0 commit comments

Comments
 (0)