Skip to content

Commit c0bdeb1

Browse files
committed
When possible show meta info from completions.
In particular with Python this include the types of the object selected. Also update the key binding to be more in line with IPython; Ctrl-O to insert a new line.
1 parent 6c8e1b0 commit c0bdeb1

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

jupyter_console/ptshell.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,26 @@ def get_completions(self, document, complete_event):
150150
code=document.text,
151151
cursor_pos=document.cursor_position
152152
)
153-
start_pos = content['cursor_start'] - document.cursor_position
154-
for m in content['matches']:
155-
yield Completion(m, start_position=start_pos, display_meta=content["metadata"].get(m, ""))
153+
meta = content["metadata"]
154+
155+
if "_jupyter_types_experimental" in meta:
156+
try:
157+
new_meta = {}
158+
for c, m in zip(
159+
content["matches"], meta["_jupyter_types_experimental"]
160+
):
161+
new_meta[c] = m["type"]
162+
meta = new_meta
163+
except:
164+
pass
165+
166+
start_pos = content["cursor_start"] - document.cursor_position
167+
for m in content["matches"]:
168+
yield Completion(
169+
m,
170+
start_position=start_pos,
171+
display_meta=meta.get(m, "?"),
172+
)
156173

157174

158175
class ZMQTerminalInteractiveShell(SingletonConfigurable):
@@ -477,6 +494,10 @@ def _(event):
477494
def _(event):
478495
event.cli.suspend_to_background()
479496

497+
@kb.add("c-o", filter=(has_focus(DEFAULT_BUFFER) & emacs_insert_mode))
498+
def _(event):
499+
event.current_buffer.insert_text("\n")
500+
480501
# Pre-populate history from IPython's history database
481502
history = InMemoryHistory()
482503
last_cell = u""

0 commit comments

Comments
 (0)