##// END OF EJS Templates
adding snake case auto complete for https://github.com/ipython/ipython/issues/9420
sagnak -
Show More
@@ -656,6 +656,15 b' class Completer(Configurable):'
656 for word in lst:
656 for word in lst:
657 if word[:n] == text and word != "__builtins__":
657 if word[:n] == text and word != "__builtins__":
658 match_append(word)
658 match_append(word)
659
660 snake_case_re = re.compile(r"[^_]+(_[^_]+)+?")
661 for lst in [self.namespace.keys(),
662 self.global_namespace.keys()]:
663 shortened = {"_".join([sub[0] for sub in word.split('_')]) : word
664 for word in lst if snake_case_re.fullmatch(word)}
665 for word in shortened.keys():
666 if word[:n] == text and word != "__builtins__":
667 match_append(shortened[word])
659 return [cast_unicode_py2(m) for m in matches]
668 return [cast_unicode_py2(m) for m in matches]
660
669
661 def attr_matches(self, text):
670 def attr_matches(self, text):
@@ -858,3 +858,11 b' def test_from_module_completer():'
858 _, matches = ip.complete('B', 'from io import B', 16)
858 _, matches = ip.complete('B', 'from io import B', 16)
859 nt.assert_in('BytesIO', matches)
859 nt.assert_in('BytesIO', matches)
860 nt.assert_not_in('BaseException', matches)
860 nt.assert_not_in('BaseException', matches)
861
862 def test_snake_case_completion():
863 ip = get_ipython()
864 ip.user_ns['some_three'] = 3
865 ip.user_ns['some_four'] = 4
866 _, matches = ip.complete("s_", "print(s_f")
867 nt.assert_in('some_three', matches)
868 nt.assert_in('some_four', matches) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now