diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 6062ea18886..1275aff8347 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -39,11 +39,6 @@ from IPython.utils.py3compat import cast_unicode_py2 from traitlets import Bool, Enum, observe -from functools import wraps - -#----------------------------------------------------------------------------- -# Globals -#----------------------------------------------------------------------------- # Public API __all__ = ['Completer','IPCompleter'] @@ -54,48 +49,6 @@ PROTECTABLES = ' ()[]{}?=\\|;:\'#*"^&' -#----------------------------------------------------------------------------- -# Work around BUG decorators. -#----------------------------------------------------------------------------- - -def _strip_single_trailing_space(complete): - """ - This is a workaround for a weird IPython/Prompt_toolkit behavior, - that can be removed once we rely on a slightly more recent prompt_toolkit - version (likely > 1.0.3). So this can likely be removed in IPython 6.0 - - cf https://github.com/ipython/ipython/issues/9658 - and https://github.com/jonathanslenders/python-prompt-toolkit/pull/328 - - The bug is due to the fact that in PTK the completer will reinvoke itself - after trying to completer to the longuest common prefix of all the - completions, unless only one completion is available. - - This logic is faulty if the completion ends with space, which can happen in - case like:: - - from foo import im - - which only matching completion is `import `. Note the leading space at the - end. So leaving a space at the end is a reasonable request, but for now - we'll strip it. - """ - - @wraps(complete) - def comp(*args, **kwargs): - text, matches = complete(*args, **kwargs) - if len(matches) == 1: - return text, [matches[0].rstrip()] - return text, matches - - return comp - - - -#----------------------------------------------------------------------------- -# Main functions and classes -#----------------------------------------------------------------------------- - def has_open_quotes(s): """Return whether a string has open quotes. @@ -1134,7 +1087,6 @@ def dispatch_custom_completer(self, text): return None - @_strip_single_trailing_space def complete(self, text=None, line_buffer=None, cursor_pos=None): """Find completions for the given text and line context. diff --git a/setup.py b/setup.py index 47ea1187523..7f8ad527c49 100755 --- a/setup.py +++ b/setup.py @@ -205,7 +205,7 @@ def run(self): 'pickleshare', 'simplegeneric>0.8', 'traitlets>=4.2', - 'prompt_toolkit>=1.0.3,<2.0.0', + 'prompt_toolkit>=1.0.4,<2.0.0', 'pygments', ]