Show More
@@ -418,7 +418,7 b' def get__all__entries(obj):' | |||||
418 | return [w for w in words if isinstance(w, string_types)] |
|
418 | return [w for w in words if isinstance(w, string_types)] | |
419 |
|
419 | |||
420 |
|
420 | |||
421 | def match_dict_keys(keys, prefix): |
|
421 | def match_dict_keys(keys, prefix, delims): | |
422 | """Used by dict_key_matches, matching the prefix to a list of keys""" |
|
422 | """Used by dict_key_matches, matching the prefix to a list of keys""" | |
423 | if not prefix: |
|
423 | if not prefix: | |
424 | return None, 0, [repr(k) for k in keys |
|
424 | return None, 0, [repr(k) for k in keys | |
@@ -430,7 +430,8 b' def match_dict_keys(keys, prefix):' | |||||
430 | except Exception: |
|
430 | except Exception: | |
431 | return None, 0, [] |
|
431 | return None, 0, [] | |
432 |
|
432 | |||
433 | token_match = re.search(r'\w*$', prefix, re.UNICODE) |
|
433 | pattern = '[^' + ''.join('\\' + c for c in delims) + ']*$' | |
|
434 | token_match = re.search(pattern, prefix, re.UNICODE) | |||
434 | token_start = token_match.start() |
|
435 | token_start = token_match.start() | |
435 | token_prefix = token_match.group() |
|
436 | token_prefix = token_match.group() | |
436 |
|
437 | |||
@@ -973,7 +974,7 b' class IPCompleter(Completer):' | |||||
973 | keys = get_keys(obj) |
|
974 | keys = get_keys(obj) | |
974 | if not keys: |
|
975 | if not keys: | |
975 | return keys |
|
976 | return keys | |
976 | closing_quote, token_offset, matches = match_dict_keys(keys, prefix) |
|
977 | closing_quote, token_offset, matches = match_dict_keys(keys, prefix, self.splitter.delims) | |
977 | if not matches: |
|
978 | if not matches: | |
978 | return matches |
|
979 | return matches | |
979 |
|
980 |
@@ -530,6 +530,11 b' def test_dict_key_completion_string():' | |||||
530 | _, matches = complete(line_buffer="d[\"a'") |
|
530 | _, matches = complete(line_buffer="d[\"a'") | |
531 | nt.assert_in("b", matches) |
|
531 | nt.assert_in("b", matches) | |
532 |
|
532 | |||
|
533 | # need to not split at delims that readline won't split at | |||
|
534 | if '-' not in ip.Completer.splitter.delims: | |||
|
535 | ip.user_ns['d'] = {'before-after': None} | |||
|
536 | _, matches = complete(line_buffer="d['before-af") | |||
|
537 | nt.assert_in('before-after', matches) | |||
533 |
|
538 | |||
534 | def test_dict_key_completion_contexts(): |
|
539 | def test_dict_key_completion_contexts(): | |
535 | """Test expression contexts in which dict key completion occurs""" |
|
540 | """Test expression contexts in which dict key completion occurs""" |
General Comments 0
You need to be logged in to leave comments.
Login now