Show More
@@ -20,13 +20,16 b' class TerminalPdb(Pdb):' | |||
|
20 | 20 | def get_prompt_tokens(cli): |
|
21 | 21 | return [(Token.Prompt, self.prompt)] |
|
22 | 22 | |
|
23 | def patch_stdout(**kwargs): | |
|
24 | return self.pt_cli.patch_stdout_context(**kwargs) | |
|
25 | ||
|
23 | 26 | if self._ptcomp is None: |
|
24 | 27 | compl = IPCompleter(shell=self.shell, |
|
25 | 28 | namespace={}, |
|
26 | 29 | global_namespace={}, |
|
27 | 30 | parent=self.shell, |
|
28 | 31 | ) |
|
29 | self._ptcomp = IPythonPTCompleter(compl) | |
|
32 | self._ptcomp = IPythonPTCompleter(compl, patch_stdout=patch_stdout) | |
|
30 | 33 | |
|
31 | 34 | self._pt_app = create_prompt_application( |
|
32 | 35 | editing_mode=getattr(EditingMode, self.shell.editing_mode.upper()), |
@@ -233,11 +233,15 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
233 | 233 | |
|
234 | 234 | editing_mode = getattr(EditingMode, self.editing_mode.upper()) |
|
235 | 235 | |
|
236 | def patch_stdout(**kwargs): | |
|
237 | return self.pt_cli.patch_stdout_context(**kwargs) | |
|
238 | ||
|
236 | 239 | self._pt_app = create_prompt_application( |
|
237 | 240 | editing_mode=editing_mode, |
|
238 | 241 | key_bindings_registry=kbmanager.registry, |
|
239 | 242 | history=history, |
|
240 |
completer=IPythonPTCompleter(shell=self |
|
|
243 | completer=IPythonPTCompleter(shell=self, | |
|
244 | patch_stdout=patch_stdout), | |
|
241 | 245 | enable_history_search=True, |
|
242 | 246 | style=style, |
|
243 | 247 | mouse_support=self.mouse_support, |
@@ -20,11 +20,14 b' import pygments.lexers as pygments_lexers' | |||
|
20 | 20 | |
|
21 | 21 | class IPythonPTCompleter(Completer): |
|
22 | 22 | """Adaptor to provide IPython completions to prompt_toolkit""" |
|
23 | def __init__(self, ipy_completer=None, shell=None): | |
|
23 | def __init__(self, ipy_completer=None, shell=None, patch_stdout=None): | |
|
24 | 24 | if shell is None and ipy_completer is None: |
|
25 | 25 | raise TypeError("Please pass shell=an InteractiveShell instance.") |
|
26 | 26 | self._ipy_completer = ipy_completer |
|
27 | 27 | self.shell = shell |
|
28 | if patch_stdout is None: | |
|
29 | raise TypeError("Please pass patch_stdout") | |
|
30 | self.patch_stdout = patch_stdout | |
|
28 | 31 | |
|
29 | 32 | @property |
|
30 | 33 | def ipy_completer(self): |
@@ -40,7 +43,7 b' class IPythonPTCompleter(Completer):' | |||
|
40 | 43 | # Some bits of our completion system may print stuff (e.g. if a module |
|
41 | 44 | # is imported). This context manager ensures that doesn't interfere with |
|
42 | 45 | # the prompt. |
|
43 |
with self. |
|
|
46 | with self.patch_stdout(): | |
|
44 | 47 | used, matches = self.ipy_completer.complete( |
|
45 | 48 | line_buffer=document.current_line, |
|
46 | 49 | cursor_pos=document.cursor_position_col |
General Comments 0
You need to be logged in to leave comments.
Login now