-
-
Notifications
You must be signed in to change notification settings - Fork 815
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
Telescope stays in insert mode after picker is closed #2766
Comments
Thanks for the detailed report! Unfortunately, this area of telescope's always been very difficult. Looks like the commit you bisected to was a revert commit for #2336 which was an attempt to fix another "cursor after picker is closed" issue. |
It looks like with this specific MRE, wrapping the callback for |
I just wanna say that I had tried to debug this issue for a couple of hours now and was about to go crazy trying to find out exactly what was causing this bug in my config, since it requires a combination of plugins to appear. I also use barbar.nvim btw. I stumbled across this issue just now and realized that I'm not alone. Thanks for doing the lord's work and looking into this! |
I suffer from the same issue. When I was trying to debug it the other day (to me it was more or less loading of |
@jamestrew Thanks for checking this out and also thanks for the pointer regarding |
@taketwo This fixes the issue for me too. Are you thinking of opening a PR on barbar? Let us know because if you don't I will. |
I've been using the workaround since last week and haven't noticed any side-effects, though I did not do much coding in this period. If you have free cycles, you are welcome to send a PR to Barbar. |
see the following resources: - taketwo@d571ecd - nvim-telescope/telescope.nvim#2766 - nvim-telescope/telescope.nvim#2785
Hey, I think we can close this issue as it's fixed by romgrk/barbar.nvim#540 ;) |
@gbprod Thanks for taking the time to submit a PR! This mitigates the issue for Barbar users. However, since the issue itself is not Barbar-specific, I believe the ticket should remain open. |
Temporary pain relief: vim.api.nvim_create_autocmd("WinLeave", {
callback = function()
if vim.bo.ft == "TelescopePrompt" and vim.fn.mode() == "i" then
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "i", false)
end
end,
}) courtesy of: #2027 (comment) |
I have this issue with terminal buffers. Since this happens with nothing but telescope installed it might be a different but related issue. Minimal local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"nvim-telescope/telescope.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
},
}) Then do
and go to the terminal buffer again. Since this enters terminal mode, the workaround has to be changed to vim.api.nvim_create_autocmd("WinLeave", {
callback = function()
if vim.bo.ft == "TelescopePrompt" and vim.fn.mode() == "i" then
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes([[<C-\><C-n>]], true, false, true), "i", false)
end
end,
}) |
This is now fixed upstream via neovim/neovim#27051 @taketwo your MRE was tremendously helpful 🙏 |
I can confirm that the issue does not reproduce on the new Neovim nightly. Also, the old unpatched version of Barbar does not cause trouble now. @jamestrew Thanks for investigating and propagating the bug report to Neovim. And I see that the patch even reached upstream Vim :) |
Description
I've started to experience the following annoying problem: after opening a file with
Telescope find_files
, Neovim goes into "insert" mode automatically. In fact, opening any Telescope picker and then just closing it, Neovim switches to "insert" mode. So far this affects only one of my machines that is on the most recent Neovim nightly (0.10.0~ubuntu1+git202311012034
). My other machines (they share the same dotfiles and Lazy lockfile) have older nightlies (most recent is0.10.0~ubuntu1+git202310091604
) and don't seem to be affected.I did some research are here are my findings.
Bisecting Telescope
I bisected Telescope history and found that with commit eb95a31 is the first one where the issue starts to happen. Older revisions are not affected.
Interaction with other plugins
Given that no-one else reported this problem, I tried to understand whether there was something special about my config. I "bisected" my plugins and found that it's the presence of https://github.com/romgrk/barbar.nvim that causes the issue. I then dug into their code and traced the problem to the following line: https://github.com/romgrk/barbar.nvim/blob/283bceab39f549c5e5228212661750704fcfcd9e/lua/barbar/state.lua#L103. Seems like reading buffer option during
BufWinLeave
event causes trouble.MRE
I set up a custom callback for
BufWinLeave
and tried to access buffer options from there, and this still caused the issue, so we can exclude https://github.com/romgrk/barbar.nvim from the MRE. Some observations about the behavior of the MRE I provided:nvim_get_option_value
that leads to reproduction. Calling other functions such asnvim_buf_get_name
is okay.nvim_get_option_value
on current buffer, the issue did not reproduce. So it is access to some other buffer that causes trouble. I don't quite understand what that buffer is, but it hasnofile
type. I assume this is some auxiliary buffer that is created by Telescope.Neovim version
Operating system and version
Ubuntu 20.04
Telescope version / branch / rev
Current HEAD (4522d7e)
checkhealth telescope
Steps to reproduce
nvim -nu minimal.lua file1 file2
(the files don't have to exist, however it's important that there are at least two of them)
:Telescope find_files
Expected behavior
File is opened and Neovim is in "normal" mode.
Actual behavior
File is opened and Neovim is in "insert" mode.
Minimal config
The text was updated successfully, but these errors were encountered: