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