##// END OF EJS Templates
Merge pull request #12280 from Carreau/unify-latex-completer
Matthias Bussonnier -
r25687:6ad74b8d merge
parent child Browse files
Show More
@@ -1708,8 +1708,6 b' class IPCompleter(Completer):'
1708 u"""Match Latex syntax for unicode characters.
1708 u"""Match Latex syntax for unicode characters.
1709
1709
1710 This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
1710 This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
1711
1712 Used on Python 3 only.
1713 """
1711 """
1714 slashpos = text.rfind('\\')
1712 slashpos = text.rfind('\\')
1715 if slashpos > -1:
1713 if slashpos > -1:
@@ -1722,7 +1720,8 b' class IPCompleter(Completer):'
1722 # If a user has partially typed a latex symbol, give them
1720 # If a user has partially typed a latex symbol, give them
1723 # a full list of options \al -> [\aleph, \alpha]
1721 # a full list of options \al -> [\aleph, \alpha]
1724 matches = [k for k in latex_symbols if k.startswith(s)]
1722 matches = [k for k in latex_symbols if k.startswith(s)]
1725 return s, matches
1723 if matches:
1724 return s, matches
1726 return u'', []
1725 return u'', []
1727
1726
1728 def dispatch_custom_completer(self, text):
1727 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