Skip to content
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

refactor: remove the fix_input hack #585

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions lua/noice/util/hacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ end
function M.enable()
M.reset_augroup()
M.fix_incsearch()
M.fix_input()
M.fix_redraw()
M.fix_cmp()
M.fix_vim_sleuth()
Expand Down Expand Up @@ -142,68 +141,6 @@ function M.fix_redraw()
end)
end

---@see https://github.com/neovim/neovim/issues/20311
M.before_input = false
function M.fix_input()
local function wrap(fn, skip, redirect)
return function(...)
if skip and skip(...) then
return fn(...)
end

local Manager = require("noice.message.manager")

-- do any updates now before blocking
M.before_input = true
Router.update()

if redirect then
require("noice.ui").redirect()
end

if not redirect then
M.hide_cursor()
end

---@type boolean, any
local ok, ret = pcall(fn, ...)

if not redirect then
M.show_cursor()
end

-- clear any message right after input
Manager.clear({ event = "msg_show", kind = { "echo", "echomsg", "" } })

M.before_input = false
if ok then
return ret
end
error(ret)
end
end

local function skip(expr)
return expr ~= nil
end
local getchar = vim.fn.getchar
local getcharstr = vim.fn.getcharstr
local inputlist = vim.fn.inputlist
-- local confirm = vim.fn.confirm

vim.fn.getchar = wrap(vim.fn.getchar, skip)
vim.fn.getcharstr = wrap(vim.fn.getcharstr, skip)
vim.fn.inputlist = wrap(vim.fn.inputlist, nil)
-- vim.fn.confirm = wrap(vim.fn.confirm, nil)

table.insert(M._disable, function()
vim.fn.getchar = getchar
vim.fn.getcharstr = getcharstr
vim.fn.inputlist = inputlist
-- vim.fn.confirm = confirm
end)
end

-- Fixes cmp cmdline position
function M.fix_cmp()
M.on_module("cmp.utils.api", function(api)
Expand Down
1 change: 0 additions & 1 deletion lua/noice/util/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ function M.is_blocking(opts)

local reason = opts.blocking and mode.blocking and "blocking"
or opts.mode and blocking_mode and ("mode:" .. mode.mode)
or opts.input and Hacks.before_input and "input"
or opts.redraw and Hacks.inside_redraw and "redraw"
or #require("noice.ui.cmdline").cmdlines > 0 and "cmdline"
or nil
Expand Down