Skip to content

Commit 82657b6

Browse files
committed
short-circuit-on-file-matcher-to-prevent-completions
1 parent 2a6cdf2 commit 82657b6

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

IPython/core/completer.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,13 @@ def file_matcher(self, context: CompletionContext) -> SimpleMatcherResult:
22132213
# starts with `/home/`, `C:\`, etc)
22142214

22152215
text = context.token
2216+
code_until_cursor = self._extract_code(context.text_until_cursor)
2217+
completion_type = self._determine_completion_context(code_until_cursor)
2218+
if completion_type == self._CompletionContextType.ATTRIBUTE:
2219+
return {
2220+
"completions": [],
2221+
"suppress": False,
2222+
}
22162223

22172224
# chars that require escaping with backslash - i.e. chars
22182225
# that readline treats incorrectly as delimiters, but we
@@ -3695,25 +3702,10 @@ def _complete(self, *, cursor_line, cursor_pos, line_buffer=None, text=None,
36953702
if isinstance(self.suppress_competing_matchers, dict)
36963703
else self.suppress_competing_matchers
36973704
)
3698-
file_matcher_id = _get_matcher_id(self.file_matcher)
3699-
python_matcher_id = _get_matcher_id(self.python_matcher)
3700-
jedi_matcher_id = _get_matcher_id(self._jedi_matcher)
3701-
# If this is attribute completion and it explicitly
3702-
# recommends suppressing the file matcher, do so.
3703-
if (
3704-
(matcher_id == python_matcher_id or matcher_id == jedi_matcher_id)
3705-
and isinstance(suppression_recommended, set)
3706-
and file_matcher_id in suppression_recommended
3707-
):
3708-
should_suppress = True
3709-
else:
3710-
should_suppress = (
3711-
(suppression_config is True)
3712-
or (
3713-
suppression_recommended
3714-
and (suppression_config is not False)
3715-
)
3716-
) and has_any_completions(result)
3705+
should_suppress = (
3706+
(suppression_config is True)
3707+
or (suppression_recommended and (suppression_config is not False))
3708+
) and has_any_completions(result)
37173709

37183710
if should_suppress:
37193711
suppression_exceptions: set[str] = result.get(

0 commit comments

Comments
 (0)