YouCompleteMe icon indicating copy to clipboard operation
YouCompleteMe copied to clipboard

Redundant line in Python doc popup

Open hippie68 opened this issue 1 year ago • 2 comments

How to reproduce: In .vimrc, put set completeopt-=preview and set completeopt+=popup. Then open a Python file and type something, for example prin. Press Ctrl-Space to show the completion menu. Press Ctrl-N to select print. A popup will appear.

The bug: As opposed to what would have happened in a preview scratch buffer, the popup will display the function signature twice (see screenshot).

ycm-popup-bug

hippie68 avatar Aug 11 '24 16:08 hippie68

Now this is an interesting case. First, this can only happen with popup. https://github.com/ycm-core/YouCompleteMe/blob/master/python/ycm/client/completion_request.py#L195-L201

If the select completion item's info does not start with extra_menu_info, we want both in the popup. These properties are populated by the server, which for python is here: https://github.com/ycm-core/ycmd/blob/master/ycmd/completers/python/python_completer.py#L269-L270 And the _BuildTypeInfo is here: https://github.com/ycm-core/ycmd/blob/master/ycmd/completers/python/python_completer.py#L416-L427

So the docstring is provided by jedi and does not include def . The type info that we build relies on jedi's definition.description, which does contain def.

Looking at the jedi API, maybe we should be using definition.name instead. Mind trying that out and reporting your experience?

bstaletic avatar Aug 11 '24 19:08 bstaletic

Nope. Replacing description with name massively hinders other parts of completion. I'm not sure we'll be able to find a proper solution...

bstaletic avatar Aug 11 '24 19:08 bstaletic