##// END OF EJS Templates
Backport PR #12280: Unify API between completers.
Matthias Bussonnier -
Show More
@@ -1699,8 +1699,6 b' class IPCompleter(Completer):'
1699 u"""Match Latex syntax for unicode characters.
1699 u"""Match Latex syntax for unicode characters.
1700
1700
1701 This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
1701 This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
1702
1703 Used on Python 3 only.
1704 """
1702 """
1705 slashpos = text.rfind('\\')
1703 slashpos = text.rfind('\\')
1706 if slashpos > -1:
1704 if slashpos > -1:
@@ -1713,7 +1711,8 b' class IPCompleter(Completer):'
1713 # If a user has partially typed a latex symbol, give them
1711 # If a user has partially typed a latex symbol, give them
1714 # a full list of options \al -> [\aleph, \alpha]
1712 # a full list of options \al -> [\aleph, \alpha]
1715 matches = [k for k in latex_symbols if k.startswith(s)]
1713 matches = [k for k in latex_symbols if k.startswith(s)]
1716 return s, matches
1714 if matches:
1715 return s, matches
1717 return u'', []
1716 return u'', []
1718
1717
1719 def dispatch_custom_completer(self, text):
1718 def dispatch_custom_completer(self, text):
@@ -224,20 +224,27 b' class TestCompleter(unittest.TestCase):'
224 nt.assert_in("\\alpha", matches)
224 nt.assert_in("\\alpha", matches)
225 nt.assert_in("\\aleph", matches)
225 nt.assert_in("\\aleph", matches)
226
226
227 def test_latex_no_results(self):
228 """
229 forward latex should really return nothing in either field if nothing is found.
230 """
231 ip = get_ipython()
232 text, matches = ip.Completer.latex_matches("\\really_i_should_match_nothing")
233 nt.assert_equal(text, "")
234 nt.assert_equal(matches, [])
235
227 def test_back_latex_completion(self):
236 def test_back_latex_completion(self):
228 ip = get_ipython()
237 ip = get_ipython()
229
238
230 # do not return more than 1 matches fro \beta, only the latex one.
239 # do not return more than 1 matches fro \beta, only the latex one.
231 name, matches = ip.complete("\\β")
240 name, matches = ip.complete("\\β")
232 nt.assert_equal(len(matches), 1)
241 nt.assert_equal(matches, ['\\beta'])
233 nt.assert_equal(matches[0], "\\beta")
234
242
235 def test_back_unicode_completion(self):
243 def test_back_unicode_completion(self):
236 ip = get_ipython()
244 ip = get_ipython()
237
245
238 name, matches = ip.complete("\\Ⅴ")
246 name, matches = ip.complete("\\Ⅴ")
239 nt.assert_equal(len(matches), 1)
247 nt.assert_equal(matches, ["\\ROMAN NUMERAL FIVE"])
240 nt.assert_equal(matches[0], "\\ROMAN NUMERAL FIVE")
241
248
242 def test_forward_unicode_completion(self):
249 def test_forward_unicode_completion(self):
243 ip = get_ipython()
250 ip = get_ipython()
General Comments 0
You need to be logged in to leave comments. Login now