nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

Fix completion menu appearance when directly below virtual text lines

Open tzachar opened this issue 2 years ago • 6 comments

The current implementation of api.get_screen_cursor does not work when completion is started right below a line of virtual text (when the entire line is virtual text). The returned window row is off by one, resulting in the completion menu hiding the current row. See the following:

b4

The fix is to use vim.fn.winline and vim.fn.wincol directly. This is after the fix:

after

tzachar avatar Jul 26 '22 07:07 tzachar

screenpos() has same problem? And winline() is broken when you have split same windows.

Shougo avatar Jul 27 '22 00:07 Shougo

@Shougo screenpos() was used originally. It is the source of the problem. Maybe its a bug with the internal implementation of nvim. Anyway, I did not have any problems with splits. Can you give a specific example?

tzachar avatar Jul 27 '22 09:07 tzachar

Anyway, I did not have any problems with splits. Can you give a specific example?

I have used winline() in pum.vim. But if split windows, it returns another window pos.

Please see the screenshot.

スクリーンショット_2022-07-27_19-22-43

Note: screenpos() returns right pos.

Shougo avatar Jul 27 '22 10:07 Shougo

I see what you are talking about. However, I don't have any idea how to otherwise solve this. Maybe we should open an issue in nvim?

tzachar avatar Jul 27 '22 13:07 tzachar

Opened an issue in nvim upstream: neovim/neovim#19543

tzachar avatar Jul 27 '22 14:07 tzachar

Looks like the upstream issue is getting no traction, and I have no idea how to debug the problem myself. I changed the pull request to solve @Shougo 's problem, such that I am explicitly working around the screenpos bug.

tzachar avatar Aug 02 '22 07:08 tzachar

This has been fixed upstream

tzachar avatar Dec 07 '22 08:12 tzachar