##// END OF EJS Templates
Make IPythonPTCompleter(shell) backward-compatible...
Min RK -
Show More
@@ -238,7 +238,7 b' class TerminalInteractiveShell(InteractiveShell):'
238 238 editing_mode=editing_mode,
239 239 key_bindings_registry=kbmanager.registry,
240 240 history=history,
241 completer=IPythonPTCompleter(self),
241 completer=IPythonPTCompleter(shell=self),
242 242 enable_history_search=True,
243 243 style=style,
244 244 mouse_support=self.mouse_support,
@@ -1,3 +1,12 b''
1 """prompt-toolkit utilities
2
3 Everything in this module is a private API,
4 not to be used outside IPython.
5 """
6
7 # Copyright (c) IPython Development Team.
8 # Distributed under the terms of the Modified BSD License.
9
1 10 import unicodedata
2 11 from wcwidth import wcwidth
3 12
@@ -13,15 +22,18 b' import pygments.lexers as pygments_lexers'
13 22
14 23 class IPythonPTCompleter(Completer):
15 24 """Adaptor to provide IPython completions to prompt_toolkit"""
16 def __init__(self, shell):
17 if isinstance(shell, IPCompleter):
18 raise TypeError("IPythonPTCompleter expects an InteractiveShell"
19 " instance in IPython 5.1, not a Completer")
25 def __init__(self, ipy_completer=None, shell=None):
26 if shell is None and ipy_completer is None:
27 raise TypeError("Please pass shell=an InteractiveShell instance.")
28 self._ipy_completer = ipy_completer
20 29 self.shell = shell
21 30
22 31 @property
23 32 def ipy_completer(self):
24 return self.shell.Completer
33 if self._ipy_completer:
34 return self._ipy_completer
35 else:
36 return self.shell.Completer
25 37
26 38 def get_completions(self, document, complete_event):
27 39 if not document.current_line.strip():
General Comments 0
You need to be logged in to leave comments. Login now