Skip to content

Commit

Permalink
Fix protection of special characters on tab completion.
Browse files Browse the repository at this point in the history
Thanks to a patch by Batz (http://github.com/batz), added unit tests.

Closes gh-36.
  • Loading branch information
fperez committed Oct 22, 2010
1 parent c94126c commit ec1f4d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion IPython/core/completer.py
Expand Up @@ -95,7 +95,7 @@
if sys.platform == 'win32':
PROTECTABLES = ' '
else:
PROTECTABLES = ' ()'
PROTECTABLES = ' ()[]{}?=\\|;:\'#*"^&'

#-----------------------------------------------------------------------------
# Main functions and classes
Expand Down
16 changes: 15 additions & 1 deletion IPython/core/tests/test_completer.py
Expand Up @@ -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:
Expand Down

0 comments on commit ec1f4d6

Please sign in to comment.