Repository: ipython/ipython

Issue:
completer latex_matches no respecting API
It return matched text even if it return no completions.

Discussion:

Patch:
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index fbe0daac7..b8f093569 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -12,4 +12,3 @@
 #
 # <full commit hash>  # initial black-format 
 # <full commit hash>  # rename something internal
-6e748726282d1acb9a4f9f264ee679c474c4b8f5  # Apply pygrade --36plus on IPython/core/tests/test_inputtransformer.py.
diff --git a/IPython/core/completer.py b/IPython/core/completer.py
index 01730fff2..9091ccad5 100644
--- a/IPython/core/completer.py
+++ b/IPython/core/completer.py
@@ -1708,8 +1708,6 @@ def latex_matches(self, text):
         u"""Match Latex syntax for unicode characters.
 
         This does both ``\\alp`` -> ``\\alpha`` and ``\\alpha`` -> ``α``
-
-        Used on Python 3 only.
         """
         slashpos = text.rfind('\\')
         if slashpos > -1:
@@ -1722,7 +1720,8 @@ def latex_matches(self, text):
                 # If a user has partially typed a latex symbol, give them
                 # a full list of options \al -> [\aleph, \alpha]
                 matches = [k for k in latex_symbols if k.startswith(s)]
-                return s, matches
+                if matches:
+                    return s, matches
         return u'', []
 
     def dispatch_custom_completer(self, text):
diff --git a/tools/configure-git-blame-ignore-revs.sh b/tools/configure-git-blame-ignore-revs.sh
old mode 100755
new mode 100644
index 390d18778..e1892ef4d
--- a/tools/configure-git-blame-ignore-revs.sh
+++ b/tools/configure-git-blame-ignore-revs.sh
@@ -1,4 +1,3 @@
-#!/bin/sh
 # Other config options for blame are markUnblamables and markIgnoredLines.
 # See docs for more details:
 # https://git-scm.com/docs/git-config#Documentation/git-config.txt-blameignoreRevsFile


Test patch:
diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py
index 2920d4539..2c19e2e01 100644
--- a/IPython/core/tests/test_completer.py
+++ b/IPython/core/tests/test_completer.py
@@ -224,20 +224,27 @@ def test_latex_completions(self):
         nt.assert_in("\\alpha", matches)
         nt.assert_in("\\aleph", matches)
 
+    def test_latex_no_results(self):
+        """
+        forward latex should really return nothing in either field if nothing is found.
+        """
+        ip = get_ipython()
+        text, matches = ip.Completer.latex_matches("\\really_i_should_match_nothing")
+        nt.assert_equal(text, "")
+        nt.assert_equal(matches, [])
+
     def test_back_latex_completion(self):
         ip = get_ipython()
 
         # do not return more than 1 matches fro \beta, only the latex one.
         name, matches = ip.complete("\\β")
-        nt.assert_equal(len(matches), 1)
-        nt.assert_equal(matches[0], "\\beta")
+        nt.assert_equal(matches, ['\\beta'])
 
     def test_back_unicode_completion(self):
         ip = get_ipython()
 
         name, matches = ip.complete("\\Ⅴ")
-        nt.assert_equal(len(matches), 1)
-        nt.assert_equal(matches[0], "\\ROMAN NUMERAL FIVE")
+        nt.assert_equal(matches, ["\\ROMAN NUMERAL FIVE"])
 
     def test_forward_unicode_completion(self):
         ip = get_ipython()