@@ -219,16 +219,24 @@ def _handle_history_reply(self, msg):
219219 items .append (cell )
220220 last_cell = cell
221221 self ._set_history (items )
222-
222+
223+ def _insert_other_input (self , cursor , content ):
224+ """Insert function for input from other frontends"""
225+ cursor .beginEditBlock ()
226+ start = cursor .position ()
227+ n = content .get ('execution_count' , 0 )
228+ cursor .insertText ('\n ' )
229+ self ._insert_html (cursor , self ._make_in_prompt (n ))
230+ cursor .insertText (content ['code' ])
231+ self ._highlighter .rehighlightBlock (cursor .block ())
232+ cursor .endEditBlock ()
233+
223234 def _handle_execute_input (self , msg ):
224235 """Handle an execute_input message"""
225236 self .log .debug ("execute_input: %s" , msg .get ('content' , '' ))
226237 if self .include_output (msg ):
227- content = msg ['content' ]
228- prompt_number = content .get ('execution_count' , 0 )
229- self ._append_html (self ._make_in_prompt (prompt_number ), True )
230- self ._append_plain_text (content ['code' ], True )
231-
238+ self ._append_custom (self ._insert_remote_input , msg ['content' ], before_prompt = True )
239+
232240
233241 def _handle_execute_result (self , msg ):
234242 """ Reimplemented for IPython-style "display hook".
0 commit comments