Show More
@@ -72,7 +72,7 b' matrix:' | |||||
72 | - arch: arm64 |
|
72 | - arch: arm64 | |
73 | python: "3.7" |
|
73 | python: "3.7" | |
74 | dist: xenial |
|
74 | dist: xenial | |
75 | env: ARM64=True |
|
75 | env: ARM64=True IPYTHON_TESTING_TIMEOUT_SCALE=2 | |
76 | sudo: true |
|
76 | sudo: true | |
77 | - arch: amd64 |
|
77 | - arch: amd64 | |
78 | python: "3.8-dev" |
|
78 | python: "3.8-dev" |
@@ -626,6 +626,8 b' class Completer(Configurable):' | |||||
626 | else: |
|
626 | else: | |
627 | self.global_namespace = global_namespace |
|
627 | self.global_namespace = global_namespace | |
628 |
|
628 | |||
|
629 | self.custom_matchers = [] | |||
|
630 | ||||
629 | super(Completer, self).__init__(**kwargs) |
|
631 | super(Completer, self).__init__(**kwargs) | |
630 |
|
632 | |||
631 | def complete(self, text, state): |
|
633 | def complete(self, text, state): | |
@@ -1122,12 +1124,14 b' class IPCompleter(Completer):' | |||||
1122 |
|
1124 | |||
1123 | if self.use_jedi: |
|
1125 | if self.use_jedi: | |
1124 | return [ |
|
1126 | return [ | |
|
1127 | *self.custom_matchers, | |||
1125 | self.file_matches, |
|
1128 | self.file_matches, | |
1126 | self.magic_matches, |
|
1129 | self.magic_matches, | |
1127 | self.dict_key_matches, |
|
1130 | self.dict_key_matches, | |
1128 | ] |
|
1131 | ] | |
1129 | else: |
|
1132 | else: | |
1130 | return [ |
|
1133 | return [ | |
|
1134 | *self.custom_matchers, | |||
1131 | self.python_matches, |
|
1135 | self.python_matches, | |
1132 | self.file_matches, |
|
1136 | self.file_matches, | |
1133 | self.magic_matches, |
|
1137 | self.magic_matches, |
@@ -2218,7 +2218,7 b' class InteractiveShell(SingletonConfigurable):' | |||||
2218 | list where you want the completer to be inserted.""" |
|
2218 | list where you want the completer to be inserted.""" | |
2219 |
|
2219 | |||
2220 | newcomp = types.MethodType(completer,self.Completer) |
|
2220 | newcomp = types.MethodType(completer,self.Completer) | |
2221 | self.Completer.matchers.insert(pos,newcomp) |
|
2221 | self.Completer.custom_matchers.insert(pos,newcomp) | |
2222 |
|
2222 | |||
2223 | def set_completer_frame(self, frame=None): |
|
2223 | def set_completer_frame(self, frame=None): | |
2224 | """Set the frame of the completer.""" |
|
2224 | """Set the frame of the completer.""" |
@@ -998,3 +998,21 b' def test_should_run_async():' | |||||
998 | assert not ip.should_run_async("a = 5") |
|
998 | assert not ip.should_run_async("a = 5") | |
999 | assert ip.should_run_async("await x") |
|
999 | assert ip.should_run_async("await x") | |
1000 | assert ip.should_run_async("import asyncio; await asyncio.sleep(1)") |
|
1000 | assert ip.should_run_async("import asyncio; await asyncio.sleep(1)") | |
|
1001 | ||||
|
1002 | ||||
|
1003 | def test_set_custom_completer(): | |||
|
1004 | num_completers = len(ip.Completer.matchers) | |||
|
1005 | ||||
|
1006 | def foo(*args, **kwargs): | |||
|
1007 | return "I'm a completer!" | |||
|
1008 | ||||
|
1009 | ip.set_custom_completer(foo, 0) | |||
|
1010 | ||||
|
1011 | # check that we've really added a new completer | |||
|
1012 | assert len(ip.Completer.matchers) == num_completers + 1 | |||
|
1013 | ||||
|
1014 | # check that the first completer is the function we defined | |||
|
1015 | assert ip.Completer.matchers[0]() == "I'm a completer!" | |||
|
1016 | ||||
|
1017 | # clean up | |||
|
1018 | ip.Completer.custom_matchers.pop() |
General Comments 0
You need to be logged in to leave comments.
Login now