Skip to content

Fix completion in indented lines dropping prefix when jedi is disabled#14474

Merged
Carreau merged 3 commits intoipython:mainfrom
krassowski:fix-completion-prefix-in-indent
Aug 30, 2024
Merged

Fix completion in indented lines dropping prefix when jedi is disabled#14474
Carreau merged 3 commits intoipython:mainfrom
krassowski:fix-completion-prefix-in-indent

Conversation

@krassowski
Copy link
Copy Markdown
Member

Fixes #14470

I would appreciate someone testing this PR.

@krassowski krassowski added the bug label Jun 27, 2024
@krassowski
Copy link
Copy Markdown
Member Author

It would be good to add an E2E test for this one, most unit tests are on lower level functions

@spreiter
Copy link
Copy Markdown

spreiter commented Jul 2, 2024

Hi,

Since I found this bug, I am happy to help as good as I can.

I created a virtual env with Python 3.11 and built the package manually based on these changes. I did the same test and it worked.

x = []
if True:
    x.so <TAB>  # completes to x.sort

I was not sure, what else needed to be tested. Another exampled however failed:

def f():
    for i in range(10):
        i. <TAB>  # should not show anything, but now crashes..


Traceback (most recent call last):
  File "/home/XXX/.virtualenvs/jedi-completion/lib/python3.11/site-packages/IPython/core/completer.py", line 3213, in _complete
    result = matcher(context)
             ^^^^^^^^^^^^^^^^
  File "/home/XXX/.virtualenvs/jedi-completion/lib/python3.11/site-packages/IPython/core/completer.py", line 2335, in python_matcher
    matches, fragment = self._attr_matches(text, include_prefix=False)
    ^^^^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)

Maybe using TAB on a not yet defined variable is not practical, but I guess failing silently might be better ;)

Happy to test other ideas!

Best,
Simon

@krassowski krassowski marked this pull request as ready for review July 3, 2024 10:27
@krassowski krassowski added this to the 8.27 milestone Jul 3, 2024
@krassowski
Copy link
Copy Markdown
Member Author

Thank you @spreiter, I fixed this now.

@spreiter
Copy link
Copy Markdown

spreiter commented Jul 3, 2024

Tried with krassowski@5827cc8 , looks good. I can currently not think of any other test...

So all in all, good work from my testing point of view.

@Carreau Carreau merged commit 5c8bc51 into ipython:main Aug 30, 2024
@krassowski krassowski deleted the fix-completion-prefix-in-indent branch August 30, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completion in indented lines incorrectly strips the prefix when jedi is disabled

3 participants