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
This commit is contained in:
fdschmidt93
2022-05-03 18:36:45 +02:00
committed by GitHub
parent e454a0ad37
commit 80e4313cc8

View File

@@ -434,24 +434,16 @@ function Picker:find()
self:set_prompt(self.default_text) self:set_prompt(self.default_text)
end end
if vim.tbl_contains({ "insert", "normal" }, self.initial_mode) then if self.initial_mode == "insert" then
vim.schedule(function() vim.schedule(function()
local mode = vim.fn.mode() -- startinsert! did not reliable do `A` no idea why, i even looked at the source code
if self.initial_mode == "normal" then
if mode ~= "n" then
a.nvim_input "<ESC>"
end
else
-- Example: live_grep -> type something -> quit -> Telescope pickers -> resume -> cursor of by one -- Example: live_grep -> type something -> quit -> Telescope pickers -> resume -> cursor of by one
-- vim.cmd doesn't schedule appropriately, bypass with `nvim_input` local mode = vim.fn.mode()
-- histdel('cmd', -1) to not pollute command history with startinsert & echon to clear "startinsert" msg
if mode ~= "i" then if mode ~= "i" then
local cmd = ":startinsert!|call histdel('cmd', -1)|echon ''<CR>" a.nvim_input(mode ~= "n" and "<ESC>A" or "A")
a.nvim_input(mode ~= "n" and "<ESC>" .. cmd or cmd)
end
end end
end) end)
else elseif self.initial_mode ~= "normal" then
error("Invalid setting for initial_mode: " .. self.initial_mode) error("Invalid setting for initial_mode: " .. self.initial_mode)
end end