Skip to content

Commit

Permalink
stdin: interrupting <C-c> works at least for owned kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
bfredl committed Sep 24, 2016
1 parent 0f2148d commit ad4007f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion rplugin/python3/nvim_ipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import re
import neovim
from neovim.api import NvimError

from jupyter_client import KernelManager
from jupyter_client.threaded import ThreadedKernelClient
Expand Down Expand Up @@ -372,6 +373,7 @@ def _on_iopub_msg(self, m):


def on_shell_msg(self, m):
self.last_msg = m
debug('shell %s: %r', m['msg_type'], m['content'])
msg_id = m['parent_header']['msg_id']
try:
Expand All @@ -390,4 +392,16 @@ def on_hb_msg(self, time_since):
self.disp_status("DEAD")

def on_stdin_msg(self, msg):
self.kc.input(self.vim.funcs.input("(IPy) " + msg["content"]["prompt"]))
self.last_msg = msg
try:
res = self.vim.funcs.input("(IPy) " + msg["content"]["prompt"])
except NvimError:
#TODO(nvim) return exceptions precisely
# for now assume keyboard interrupt
self.ipy_interrupt([])
return

if self.last_msg is msg:
# from jupyter_console, input should be considered to be interrupted
# if there was another message
self.kc.input(res)

0 comments on commit ad4007f

Please sign in to comment.