-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
inccommand: nvim_buf_set_text causes cursor flickering #30696
Comments
nvim_buf_set_text
causes cursor flickering
Flicker caused by non-trivial functions, especially RPC/API (though this case is not RPC), is kind of a general, known topic, but I couldn't find tracking issue. |
This only happens with treesitter because treesitter uses |
Hmm, there is a difference between different options of
|
Unrelated but I found that it still happens even after The issue also happens when calling anything else that flushes the cursor position at msg_row/col still at the end of the newly changed cmdline. I.e. the following reproduces the flickering also without treesitter enabled: local function replace_first_line_preview(opts, preview_ns, preview_buf)
local replacement = opts.args
vim.api.nvim_buf_set_text(0, 0, 0, 1, -1, { replacement })
vim.cmd.sleep("1m")
-- vim.cmd.redrawtabline()
return 2
end
vim.treesitter.stop()
vim.api.nvim_create_user_command(
"ReplaceFirstLine",
function() end,
{ nargs = 1, preview = replace_first_line_preview }
) Unlikely that any of those commands make sense to call inside the cmdpreview callback but I think it does indicate that a proper solution would be to ensure that the cursor is at the correct position before doing cmdpreview: #31040.
True, do you think that presents a problem intrinsically? Currently
True except for statuscolumn which does require
Yeah We can either keep the Or we can special case Further findings: On top of the So I think calling |
Problem
When typing an argument of a previewable command in command line mode (only on some key presses), the cursor is briefly moved to the end of the text. This only occurs when the buffer text is changed using
vim.api.nvim_buf_set_text
in the preview callback.Initially reported here (the recording might be useful): smjonas/inc-rename.nvim#63
Steps to reproduce
nvim --clean
:e test.lua
Paste the following Lua code:
:so %
:ReplaceFirstLine a
a
's (hold thea
key if the flicker is not immediately visible)Observe that while typing some
a
's, the cursor is briefly moved to the right of the lasta
before being reset to the current position. position.Expected behavior
Cursor should not flicker.
Nvim version (nvim -v)
NVIM v0.11.0-dev-911+ga2008118a
Vim (not Nvim) behaves the same?
n/a
Operating system/version
Linux Mint 21.2
Terminal name/version
Kitty 0.21.2
$TERM environment variable
xterm-kitty
Installation
appimage
The text was updated successfully, but these errors were encountered: