Skip to content

Commit 6220937

Browse files
committed
improve-completer
1 parent 5a3bf34 commit 6220937

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

IPython/core/completer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,9 @@ def attr_matches(self, text):
11371137
def _attr_matches(
11381138
self, text: str, include_prefix: bool = True
11391139
) -> tuple[Sequence[str], str]:
1140-
m2 = self._ATTR_MATCH_RE.match(text)
1140+
# Extract only the right-hand side part of the text after '='
1141+
rhs_text = text.split("=")[-1]
1142+
m2 = self._ATTR_MATCH_RE.match(rhs_text)
11411143
if not m2:
11421144
return [], ""
11431145
expr, attr = m2.group(1, 2)

tests/test_completer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ def test_greedy_completions(self):
597597
ip = get_ipython()
598598
ip.ex("a=list(range(5))")
599599
ip.ex("d = {'a b': str}")
600+
ip.ex("x=y='a'")
600601
_, c = ip.complete(".", line="a[0].")
601602
self.assertFalse(".real" in c, "Shouldn't have completed on a[0]: %s" % c)
602603

@@ -654,6 +655,13 @@ def _(line, cursor_pos, expect, message, completion):
654655
"Should have completed on `a.app`: %s",
655656
Completion(2, 4, "append"),
656657
)
658+
_(
659+
"x.upper() == y.",
660+
15,
661+
".upper",
662+
"Should have completed on `x.upper() == y.`: %s",
663+
Completion(15, 15, "upper"),
664+
)
657665

658666
def test_omit__names(self):
659667
# also happens to test IPCompleter as a configurable

0 commit comments

Comments
 (0)