Open mawkler opened 1 year ago
When checking the mode with vim.api.nvim_get_mode().mode it sometimes evaluates to i (insert) and sometimes n (normal), despite always staying in insert mode.
I would try to get the mode via vim.fn.mode()
. I loosely recall from various uses of vim.api.nvim_get_mode
that it can be quite flaky in telescope context (e.g., initial mode setting).
When typing in insert mode in telescope's prompt
What happens when you type in the telescope prompt is that on_lines
from nvim_buf_attach
callbacks send the content of the prompt to the finder, which would be my initial hunch as to why ModeChanged
occurs (couldn't think of anything else).
vim.api.nvim_get_mode()
, unlike vim.fn.mode()
I believe, works in :h api-fast
contexts, which is why I suppose you observe changing modes on on_lines
callbacks. This is however only my best guess.
No clue if ModeChanged
could be avoided, if it stems from what I'm hypothesizing it does.
I did try out using vim.fn.mode
in the minimal config example but it produces the same result.
But I think your hunch is right that the on_lines
, specifically the sending of the on_lines
content over a channel or rather some of the async stuff we do on the receiving end is probably the culprit.
This issue is only reproducible with previewer enabled. If you do :Telescope builtin previewer=false
The preview window/buffer sometimes needs to switch modes to do some jumping or similar, this is expected behavior.
preview scrolling e.g. also switches modes https://github.com/nvim-telescope/telescope.nvim/blob/74ce793a60759e3db0d265174f137fb627430355/lua/telescope/previewers/buffer_previewer.lua#L318-L320
Why is this an issue for you? And if its not really an issue for you can this be closed?
@Conni2461 This is the reason I opened the issue: https://github.com/mawkler/modicator.nvim/issues/17
Description
When typing in insert mode in telescope's prompt, Telescope sends various
ModeChanged
commands. When checking the mode withvim.api.nvim_get_mode().mode
it sometimes evaluates toi
(insert) and sometimesn
(normal), despite always staying in insert mode.Neovim version
Operating system and version
Manjaro Linux x86_64
Telescope version / branch / rev
31b05ad
checkhealth telescope
Steps to reproduce
nvim -nu init.lua
:Telescope
lsp type
while looking at the mode that gets printed at the bottom leftExpected behavior
Telescope doesn't send any
ModeChanged
autocommand while typing in insert modeActual behavior
The mode changes between
i
andn
even though we're always in insert mode while typingMinimal config