##// END OF EJS Templates
Fix backslash combining matchers (they require `text_until_cursor`).
krassowski -
Show More
@@ -1228,12 +1228,12 b' def _safe_isinstance(obj, module, class_name):'
1228
1228
1229
1229
1230 @context_matcher()
1230 @context_matcher()
1231 def back_unicode_name_matcher(context):
1231 def back_unicode_name_matcher(context: CompletionContext):
1232 """Match Unicode characters back to Unicode name
1232 """Match Unicode characters back to Unicode name
1233
1233
1234 Same as :any:`back_unicode_name_matches`, but adopted to new Matcher API.
1234 Same as :any:`back_unicode_name_matches`, but adopted to new Matcher API.
1235 """
1235 """
1236 fragment, matches = back_unicode_name_matches(context.token)
1236 fragment, matches = back_unicode_name_matches(context.text_until_cursor)
1237 return _convert_matcher_v1_result_to_v2(
1237 return _convert_matcher_v1_result_to_v2(
1238 matches, type="unicode", fragment=fragment, suppress_if_matches=True
1238 matches, type="unicode", fragment=fragment, suppress_if_matches=True
1239 )
1239 )
@@ -1282,12 +1282,12 b' def back_unicode_name_matches(text: str) -> Tuple[str, Sequence[str]]:'
1282
1282
1283
1283
1284 @context_matcher()
1284 @context_matcher()
1285 def back_latex_name_matcher(context):
1285 def back_latex_name_matcher(context: CompletionContext):
1286 """Match latex characters back to unicode name
1286 """Match latex characters back to unicode name
1287
1287
1288 Same as :any:`back_latex_name_matches`, but adopted to new Matcher API.
1288 Same as :any:`back_latex_name_matches`, but adopted to new Matcher API.
1289 """
1289 """
1290 fragment, matches = back_latex_name_matches(context.token)
1290 fragment, matches = back_latex_name_matches(context.text_until_cursor)
1291 return _convert_matcher_v1_result_to_v2(
1291 return _convert_matcher_v1_result_to_v2(
1292 matches, type="latex", fragment=fragment, suppress_if_matches=True
1292 matches, type="latex", fragment=fragment, suppress_if_matches=True
1293 )
1293 )
@@ -2255,9 +2255,9 b' class IPCompleter(Completer):'
2255 return [leading + k + suf for k in matches]
2255 return [leading + k + suf for k in matches]
2256
2256
2257 @context_matcher()
2257 @context_matcher()
2258 def unicode_name_matcher(self, context):
2258 def unicode_name_matcher(self, context: CompletionContext):
2259 """Same as :any:`unicode_name_matches`, but adopted to new Matcher API."""
2259 """Same as :any:`unicode_name_matches`, but adopted to new Matcher API."""
2260 fragment, matches = self.unicode_name_matches(context.token)
2260 fragment, matches = self.unicode_name_matches(context.text_until_cursor)
2261 return _convert_matcher_v1_result_to_v2(
2261 return _convert_matcher_v1_result_to_v2(
2262 matches, type="unicode", fragment=fragment, suppress_if_matches=True
2262 matches, type="unicode", fragment=fragment, suppress_if_matches=True
2263 )
2263 )
@@ -2285,12 +2285,12 b' class IPCompleter(Completer):'
2285 return '', []
2285 return '', []
2286
2286
2287 @context_matcher()
2287 @context_matcher()
2288 def latex_name_matcher(self, context):
2288 def latex_name_matcher(self, context: CompletionContext):
2289 """Match Latex syntax for unicode characters.
2289 """Match Latex syntax for unicode characters.
2290
2290
2291 This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
2291 This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
2292 """
2292 """
2293 fragment, matches = self.latex_matches(context.token)
2293 fragment, matches = self.latex_matches(context.text_until_cursor)
2294 return _convert_matcher_v1_result_to_v2(
2294 return _convert_matcher_v1_result_to_v2(
2295 matches, type="latex", fragment=fragment, suppress_if_matches=True
2295 matches, type="latex", fragment=fragment, suppress_if_matches=True
2296 )
2296 )
@@ -2857,9 +2857,12 b' class IPCompleter(Completer):'
2857 return sorted(matches, key=lambda x: completions_sorting_key(x.text))
2857 return sorted(matches, key=lambda x: completions_sorting_key(x.text))
2858
2858
2859 @context_matcher()
2859 @context_matcher()
2860 def fwd_unicode_matcher(self, context):
2860 def fwd_unicode_matcher(self, context: CompletionContext):
2861 """Same as :any:`fwd_unicode_match`, but adopted to new Matcher API."""
2861 """Same as :any:`fwd_unicode_match`, but adopted to new Matcher API."""
2862 fragment, matches = self.latex_matches(context.token)
2862 # TODO: use `context.limit` to terminate early once we matched the maximum
2863 # number that will be used downstream; can be added as an optional to
2864 # `fwd_unicode_match(text: str, limit: int = None)` or we could re-implement here.
2865 fragment, matches = self.fwd_unicode_match(context.text_until_cursor)
2863 return _convert_matcher_v1_result_to_v2(
2866 return _convert_matcher_v1_result_to_v2(
2864 matches, type="unicode", fragment=fragment, suppress_if_matches=True
2867 matches, type="unicode", fragment=fragment, suppress_if_matches=True
2865 )
2868 )
@@ -1295,6 +1295,18 b' class TestCompleter(unittest.TestCase):'
1295 for c in completions:
1295 for c in completions:
1296 self.assertEqual(c.text[0], "%")
1296 self.assertEqual(c.text[0], "%")
1297
1297
1298 def test_fwd_unicode_restricts(self):
1299 ip = get_ipython()
1300 completer = ip.Completer
1301 text = "\\ROMAN NUMERAL FIVE"
1302
1303 with provisionalcompleter():
1304 completer.use_jedi = True
1305 completions = [
1306 completion.text for completion in completer.completions(text, len(text))
1307 ]
1308 self.assertEqual(completions, ["\u2164"])
1309
1298 def test_dict_key_restrict_to_dicts(self):
1310 def test_dict_key_restrict_to_dicts(self):
1299 """Test that dict key suppresses non-dict completion items"""
1311 """Test that dict key suppresses non-dict completion items"""
1300 ip = get_ipython()
1312 ip = get_ipython()
General Comments 0
You need to be logged in to leave comments. Login now