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

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

Open
strange opened this issue Jan 7, 2022 · 6 comments
Open

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

strange opened this issue Jan 7, 2022 · 6 comments

Comments

@strange
Copy link

strange commented Jan 7, 2022

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
Copy link
Owner

AckslD commented Jan 9, 2022

@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
Copy link

fdschmidt93 commented Jan 9, 2022

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

define_preview = function(self, entry, status)
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, true, entry.contents)
if entry.filetype ~= nil then
vim.bo[self.state.bufnr].filetype = entry.filetype
end
end,

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
Copy link
Owner

AckslD commented Jan 9, 2022

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

@AckslD
Copy link
Owner

AckslD commented Jan 9, 2022

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
Copy link
Author

strange commented Jan 12, 2022

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

@AckslD
Copy link
Owner

AckslD commented Jan 12, 2022

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.

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

3 participants