Skip to content

Commit

Permalink
Merge pull request jupyter#119 from wilywampa/update_count
Browse files Browse the repository at this point in the history
Update execution_count before running cell
  • Loading branch information
minrk authored Feb 21, 2017
2 parents b1f72aa + 1b1d27e commit e1af67b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions jupyter_console/ptshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ def _(event):
b.newline()
return

# Pressing enter flushes any pending display. This also ensures
# the displayed execution_count is correct.
self.handle_iopub()

more, indent = self.check_complete(d.text)

if (not more) and b.accept_action.is_returnable:
Expand Down Expand Up @@ -663,6 +667,10 @@ def handle_iopub(self, msg_id=''):
msg_type = sub_msg['header']['msg_type']
parent = sub_msg["parent_header"]

# Update execution_count in case it changed in another session
if msg_type == "execute_input":
self.execution_count = int(sub_msg["content"]["execution_count"]) + 1

if self.include_output(sub_msg):
if msg_type == 'status':
self._execution_state = sub_msg["content"]["execution_state"]
Expand Down

0 comments on commit e1af67b

Please sign in to comment.