Is your feature request related to a problem? Please describe.
coc#float#scroll which works in normal and insert mode. Sadly (tested on nvim 0.4.4), it doesn't work on visual mode, which is an important use case on snippet expansion and jump placeholder.Describe the solution you'd like
I wished it could be made to work as it works for insert and normal mode.
Describe alternatives you've considered
coc#util#float_scroll_i, which was added before #2472, can scroll in visual mode, the problem is that it was not improved to handle the scrollbar that was introduced by #2472, so even though it scrolls, the scrollbar is static on top, it never updates.
I'm not sure whether code from coc#util#float_scroll_i can be used as reference to make coc#float#scroll work in visual mode, or whether coc#util#float_scroll_i can be improved to update scrollbar position. I tried the latter by appending a call to coc#float#nvim_scrollbar to it but it didn't work.
Additional context
I commented about this here, so I'm just opening this new issue so that won't get lost in comments.
Nope, it can't be correct IMO
Oh, just managed to make coc#util#float_scroll_i to update the scrollbar state in visual mode, I just had to use the timer_start hack instead of calling coc#float#nvim_scrollbar directly:
diff --git a/autoload/coc/util.vim b/autoload/coc/util.vim
index 08ee758..9ead5e0 100644
--- a/autoload/coc/util.vim
+++ b/autoload/coc/util.vim
@@ -115,6 +115,7 @@ function! coc#util#float_scroll_i(amount)
endif
call nvim_win_set_var(float, 'coc_float_scroll_last_amount', a:amount)
call nvim_win_set_cursor(float, pos)
+ call timer_start(10, { -> coc#float#nvim_scrollbar(float) })
return ''
endfunction
My current mappings after that patch being applied locally:
let g:coc_snippet_next = '<c-l>'
let g:coc_snippet_prev = '<c-h>'
nnoremap <silent><expr> <c-j> coc#float#has_scroll() ? coc#float#scroll(1, 1) : "\<c-j>"
nnoremap <silent><expr> <c-k> coc#float#has_scroll() ? coc#float#scroll(0, 1) : "\<c-k>"
inoremap <silent><expr> <c-j> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1, 1)\<cr>" : "\<c-j>"
inoremap <silent><expr> <c-k> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0, 1)\<cr>" : "\<c-k>"
vnoremap <silent><expr> <c-j> coc#float#has_scroll() ? coc#util#float_scroll_i( 1) : "\<c-j>"
vnoremap <silent><expr> <c-k> coc#float#has_scroll() ? coc#util#float_scroll_i(-1) : "\<c-k>"

Nope, it can't be correct IMO
Sorry, I didn't get what you mean. Do you mean there isn't a way to implement it correctly? (coc#util#float_scroll_i is not ideal as it still miss correct scroll on wrapped text, though it's still useful)
It's neovim only and could be not work at all
Okay, I'll send a PR then, to add this line to sync the scrollbar. So that coc#util#float_scroll_i works a bit better. Maybe should rename it to coc#util#float_scroll_v to make it more explicit it's solely useful for visual mode, given coc#float#scroll doesn't work with that.
Partially solved by #2532. Maybe futurely coc#float#scroll will be able to handle this :)
It can't be correct unless neovim provide win_execute function or support winid for line().
It can't be correct unless neovim provide
win_executefunction or supportwinidforline().
@chemzqm, I just learned that in neovim exists :h <Cmd>, and the docs has something about it not changing modes, while executing complex stuff. Not sure whether it may be useful for this.
No, it's caused by cursor have to move to another window
@chemzqm hm, okay.