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