Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f6e3393

Browse files
ygeyzelCarreau
authored andcommitted
Typing '%' restrict autocompletion to magics
1 parent 935dedb commit f6e3393

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

IPython/core/completer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,8 +2139,9 @@ def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None,
21392139
# different types of objects. The rlcomplete() method could then
21402140
# simply collapse the dict into a list for readline, but we'd have
21412141
# richer completion semantics in other environments.
2142-
completions:Iterable[Any] = []
2143-
if self.use_jedi:
2142+
is_magic_prefix = len(text) > 0 and text[0] == "%"
2143+
completions: Iterable[Any] = []
2144+
if self.use_jedi and not is_magic_prefix:
21442145
if not full_text:
21452146
full_text = line_buffer
21462147
completions = self._jedi_matches(

IPython/core/tests/test_completer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,3 +1262,14 @@ def meth_2(self, meth2_arg1, meth2_arg2):
12621262
_, matches = ip.complete(None, "test.meth(")
12631263
self.assertIn("meth_arg1=", matches)
12641264
self.assertNotIn("meth2_arg1=", matches)
1265+
1266+
def test_percent_symbol_restrict_to_magic_completions(self):
1267+
ip = get_ipython()
1268+
completer = ip.Completer
1269+
text = "%a"
1270+
1271+
with provisionalcompleter():
1272+
completer.use_jedi = True
1273+
completions = completer.completions(text, len(text))
1274+
for c in completions:
1275+
self.assertEqual(c.text[0], "%")

0 commit comments

Comments
 (0)