##// END OF EJS Templates
Make IPythonPTCompleter(shell) backward-compatible...
Min RK -
Show More
@@ -238,7 +238,7 b' class TerminalInteractiveShell(InteractiveShell):'
238 editing_mode=editing_mode,
238 editing_mode=editing_mode,
239 key_bindings_registry=kbmanager.registry,
239 key_bindings_registry=kbmanager.registry,
240 history=history,
240 history=history,
241 completer=IPythonPTCompleter(self),
241 completer=IPythonPTCompleter(shell=self),
242 enable_history_search=True,
242 enable_history_search=True,
243 style=style,
243 style=style,
244 mouse_support=self.mouse_support,
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 import unicodedata
10 import unicodedata
2 from wcwidth import wcwidth
11 from wcwidth import wcwidth
3
12
@@ -13,15 +22,18 b' import pygments.lexers as pygments_lexers'
13
22
14 class IPythonPTCompleter(Completer):
23 class IPythonPTCompleter(Completer):
15 """Adaptor to provide IPython completions to prompt_toolkit"""
24 """Adaptor to provide IPython completions to prompt_toolkit"""
16 def __init__(self, shell):
25 def __init__(self, ipy_completer=None, shell=None):
17 if isinstance(shell, IPCompleter):
26 if shell is None and ipy_completer is None:
18 raise TypeError("IPythonPTCompleter expects an InteractiveShell"
27 raise TypeError("Please pass shell=an InteractiveShell instance.")
19 " instance in IPython 5.1, not a Completer")
28 self._ipy_completer = ipy_completer
20 self.shell = shell
29 self.shell = shell
21
30
22 @property
31 @property
23 def ipy_completer(self):
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 def get_completions(self, document, complete_event):
38 def get_completions(self, document, complete_event):
27 if not document.current_line.strip():
39 if not document.current_line.strip():
General Comments 0
You need to be logged in to leave comments. Login now