Skip to content

Commit fde243e

Browse files
committed
autocompletion sends busy/idle messages; fixes autocomplete in Jupyter lab
1 parent d51aef1 commit fde243e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

custom_components/pyscript/eval.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,8 @@ def completions(self, root):
11721172
for name, value in sym_table.items():
11731173
if name.lower().startswith(root):
11741174
if callable(value) or isinstance(value, EvalFunc):
1175-
words.add(f"{name}(")
1175+
# used to be f"{name}(", but Jupyter doesn't always do the right thing with that
1176+
words.add(name)
11761177
else:
11771178
words.add(name)
11781179
return words

custom_components/pyscript/jupyter_kernel.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@ async def shell_handler(self, msg):
296296
}
297297
await self.send(self.iopub_socket, 'status', content, parent_header=msg['header'])
298298
elif msg['header']["msg_type"] == "complete_request":
299+
content = {
300+
'execution_state': "busy",
301+
}
302+
await self.send(self.iopub_socket, 'status', content, parent_header=msg['header'])
303+
299304
code = msg["content"]["code"]
300305
posn = msg["content"]["cursor_pos"]
301306
match = self.completion_re.match(code[0:posn].lower())
@@ -317,6 +322,11 @@ async def shell_handler(self, msg):
317322
"metadata": {},
318323
}
319324
await self.send(self.shell_socket, 'complete_reply', content, parent_header=msg['header'], identities=identities)
325+
326+
content = {
327+
'execution_state': "idle",
328+
}
329+
await self.send(self.iopub_socket, 'status', content, parent_header=msg['header'])
320330
elif msg['header']["msg_type"] == "is_complete_request":
321331
code = msg['content']["code"]
322332
self.ast_ctx.parse(code)

0 commit comments

Comments
 (0)