AckslD / nvim-neoclip.lua

Clipboard manager neovim plugin with telescope integration
944 stars 20 forks source link

Holding <C-j> and <C-k> doesn't scroll between items smoothly #39

Open strange opened 2 years ago

strange commented 2 years ago

Steps to reproduce:

Open up the telescope picker, with < 1000 pastes visible, press and hold down <C-k>.

Expected outcome:

The list should scroll smoothly (as with Telescope find_files).

Actual outcome:

Nothing happens until I release the keys. The cursor then moves to the selected item.

Problem:

Have to hold down Ctrl and press k repeatedly to navigate the history.

Context:

NVIM v0.7.0-dev+661-g99f6260f8
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -DNVIM_TS_HAS_SET_MATCH_LIMIT -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/home/gs/sr c/checkouts/neovim/build/config -I/home/gs/src/checkouts/neovim/src -I/home/gs/src/checkouts/neovim/.deps/usr/include -I/usr/include -I/home/gs/src/checkouts/neovim/build/src/nvim/auto -I/home/gs/src/c heckouts/neovim/build/include
Compiled by gs@strangepad

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/local/share/nvim"

AckslD commented 2 years ago

@strange Thanks for reporting this! I can reproduce (with j/k in normal mode). I wonder if the loading of the preview buffer interferes with the handling of key-presses. Not sure how one should handle this better in the telescope extension. Would probably have to ask someone who is better than me on telescope internals. I wonder if @fdschmidt93 might know?

fdschmidt93 commented 2 years ago

I wonder if the loading of the preview buffer interferes with the handling of key-presses.

I think that's because the preview buffers in telescope are cached, whereas at first glance they don't seem to be in neoclip.

It's a bit entrenched in the buffer previewer logic but the file is only read if the buffer name does not constitute the file name as per this line

which is then set after initial file reading here in telescope

On the contrary, you seem to be nvim_buf_set_lines the preview buffers on every preview

https://github.com/AckslD/nvim-neoclip.lua/blob/6e5d6dbf242c3c3fd55a3521368808490a86ce62/lua/neoclip/telescope.lua#L142-L147

In brief, I guess the solution would be to define a separate function for get_buffer_by_name I guess conditional on the entry (i.e. this function signature).

I hope my hunch is correct :)

AckslD commented 2 years ago

Thanks a lot @fdschmidt93! This makes a lot of sense, I'll try to fix this :)

AckslD commented 2 years ago

I'm not sure if I actually understand how this works. In #42 I just tried to specify get_buffer_by_name as a dummy function always returning the string "test" and it does seem to improve the scroll. @strange does that branch also solve the issue for you?

strange commented 2 years ago

@AckslD Unfortunately it does not seem to help. Turning off preview works though, so you're on the right track.

AckslD commented 2 years ago

Thanks for checking @strange! Hmm, strange (no pun intended), the change made the scrolling smoother for me. Maybe it depended on what specific entries I had in the history at that time.