From c054a21cd22cef41c62ce96247040abccaab8dbc Mon Sep 17 00:00:00 2001 From: bhagwan Date: Tue, 31 Dec 2024 14:24:29 -0800 Subject: [PATCH] fix: user autocmd for `TermOpen|startinsert` (closes #1659) --- lua/fzf-lua/fzf.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/fzf-lua/fzf.lua b/lua/fzf-lua/fzf.lua index 5c537047..d82f6995 100644 --- a/lua/fzf-lua/fzf.lua +++ b/lua/fzf-lua/fzf.lua @@ -231,7 +231,11 @@ function M.raw_fzf(contents, fzf_cli_args, opts) -- reason, for example, running `builtin` and opening another picker vim.defer_fn(function() -- Prevents inserting "i" when spamming `ctrl-g` in `grep_lgrep` - if vim.api.nvim_buf_is_valid(e.buf) then + -- Also verify we're not already in TERMINAL mode, could happen + -- if the user has an autocmd for TermOpen with `startinsert` + if vim.api.nvim_buf_is_valid(e.buf) + and vim.api.nvim_get_mode().mode ~= "t" + then utils.feed_keys_termcodes("i") end end, 0)