From ec1f4d67f26e2155ec082c858429f1ad0fdf6524 2010-10-22 07:34:19 From: Fernando Perez Date: 2010-10-22 07:34:19 Subject: [PATCH] Fix protection of special characters on tab completion. Thanks to a patch by Batz (http://github.com/batz), added unit tests. Closes gh-36. --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index b4b83e1..90c12af 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -95,7 +95,7 @@ __all__ = ['Completer','IPCompleter'] if sys.platform == 'win32': PROTECTABLES = ' ' else: - PROTECTABLES = ' ()' + PROTECTABLES = ' ()[]{}?=\\|;:\'#*"^&' #----------------------------------------------------------------------------- # Main functions and classes diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index 43ac8f4..f3c3a57 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -24,11 +24,25 @@ def test_protect_filename(): ('a bc',r'a\ \ bc'), (' bc',r'\ \ bc'), ] - # On posix, we also protect parens + # On posix, we also protect parens and other special characters if sys.platform != 'win32': pairs.extend( [('a(bc',r'a\(bc'), ('a)bc',r'a\)bc'), ('a( )bc',r'a\(\ \)bc'), + ('a[1]bc', r'a\[1\]bc'), + ('a{1}bc', r'a\{1\}bc'), + ('a#bc', r'a\#bc'), + ('a?bc', r'a\?bc'), + ('a=bc', r'a\=bc'), + ('a\\bc', r'a\\bc'), + ('a|bc', r'a\|bc'), + ('a;bc', r'a\;bc'), + ('a:bc', r'a\:bc'), + ("a'bc", r"a\'bc"), + ('a*bc', r'a\*bc'), + ('a"bc', r'a\"bc'), + ('a^bc', r'a\^bc'), + ('a&bc', r'a\&bc'), ] ) # run the actual tests for s1, s2 in pairs: