Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for check if there is a slection of the completion #5063

Closed
Kaiser-Yang opened this issue Jun 28, 2024 · 1 comment
Closed

API for check if there is a slection of the completion #5063

Kaiser-Yang opened this issue Jun 28, 2024 · 1 comment

Comments

@Kaiser-Yang
Copy link
Contributor

Kaiser-Yang commented Jun 28, 2024

Problem

I use this command to map my <CR>:

inoremap <silent><expr> <CR>
    \ coc#pum#visible() ? coc#pum#confirm() :
    \ CopilotVisible() ? copilot#Accept() : "\<C-g>u\<CR><C-r>=AutoPairsReturn()\<cr>"

This is simple, let me explain. <CR> will confirm completion from coc if there is a completion list, when there is no coc completion visible, and try to accept the copilot suggestions.

The problem is sometimes, when I input very quickly, and I press enter, this may confirm the coc completion. So I set noselect in coc-settings.json, but I must press <CR> twice to input a new line when there is a coc completion list.

Preferred Solution

Solution can be a new api for check if there is a selection of the coc completion, may be coc#pum#has_item_selected() or something like this to check if there is one selected item in the list. With this, I can simply update my mapping command with this below (after this, I only need press <cr> once to input a new line with noselect=true):

inoremap <silent><expr> <CR>
    \ coc#pum#has_item_selected() ? coc#pum#confirm() :
    \ CopilotVisible() ? copilot#Accept() : "\<C-g>u\<CR><C-r>=AutoPairsReturn()\<cr>"

Is this possible to be implemented?

@Kaiser-Yang
Copy link
Contributor Author

I am working on this, pr comming soon.

Kaiser-Yang added a commit to Kaiser-Yang/coc.nvim that referenced this issue Jun 28, 2024
This commit add a function to check if there is a item selected in
completion list.

Solve neoclide#5063.
Kaiser-Yang added a commit to Kaiser-Yang/coc.nvim that referenced this issue Jun 28, 2024
This commit add a function to check if there is a item selected in
completion list.

Solve neoclide#5063.
fannheyward pushed a commit that referenced this issue Jun 28, 2024
This commit add a function to check if there is a item selected in
completion list.

Solve #5063.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants