diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 89b55d2..0579e68 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -2139,8 +2139,9 @@ class IPCompleter(Completer): # different types of objects. The rlcomplete() method could then # simply collapse the dict into a list for readline, but we'd have # richer completion semantics in other environments. - completions:Iterable[Any] = [] - if self.use_jedi: + is_magic_prefix = len(text) > 0 and text[0] == "%" + completions: Iterable[Any] = [] + if self.use_jedi and not is_magic_prefix: if not full_text: full_text = line_buffer completions = self._jedi_matches( diff --git a/IPython/core/tests/test_completer.py b/IPython/core/tests/test_completer.py index 5f791e8..746a1e6 100644 --- a/IPython/core/tests/test_completer.py +++ b/IPython/core/tests/test_completer.py @@ -1262,3 +1262,14 @@ class TestCompleter(unittest.TestCase): _, matches = ip.complete(None, "test.meth(") self.assertIn("meth_arg1=", matches) self.assertNotIn("meth2_arg1=", matches) + + def test_percent_symbol_restrict_to_magic_completions(self): + ip = get_ipython() + completer = ip.Completer + text = "%a" + + with provisionalcompleter(): + completer.use_jedi = True + completions = completer.completions(text, len(text)) + for c in completions: + self.assertEqual(c.text[0], "%")