From 80e4313cc893c1df8a20c5760237afefc875afa2 Mon Sep 17 00:00:00 2001 From: fdschmidt93 <39233597+fdschmidt93@users.noreply.github.com> Date: Tue, 3 May 2022 18:36:45 +0200 Subject: [PATCH] Revert "fix(pickers): misc initial_mode setting fixes (#1895)" (#1914) Reverts circumventing A for initial_mode insert as many more users have issues with the current (failed attempt at a) fix --- lua/telescope/pickers.lua | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 3cf180f..77f88f3 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -434,24 +434,16 @@ function Picker:find() self:set_prompt(self.default_text) end - if vim.tbl_contains({ "insert", "normal" }, self.initial_mode) then + if self.initial_mode == "insert" then vim.schedule(function() + -- startinsert! did not reliable do `A` no idea why, i even looked at the source code + -- Example: live_grep -> type something -> quit -> Telescope pickers -> resume -> cursor of by one local mode = vim.fn.mode() - if self.initial_mode == "normal" then - if mode ~= "n" then - a.nvim_input "" - end - else - -- Example: live_grep -> type something -> quit -> Telescope pickers -> resume -> cursor of by one - -- vim.cmd doesn't schedule appropriately, bypass with `nvim_input` - -- histdel('cmd', -1) to not pollute command history with startinsert & echon to clear "startinsert" msg - if mode ~= "i" then - local cmd = ":startinsert!|call histdel('cmd', -1)|echon ''" - a.nvim_input(mode ~= "n" and "" .. cmd or cmd) - end + if mode ~= "i" then + a.nvim_input(mode ~= "n" and "A" or "A") end end) - else + elseif self.initial_mode ~= "normal" then error("Invalid setting for initial_mode: " .. self.initial_mode) end