Skip to content

Commit

Permalink
refactor: remove the fix_input hack
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaSolOs committed Sep 3, 2023
1 parent 74c2902 commit 81bf07a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 64 deletions.
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

0 comments on commit 81bf07a

Please sign in to comment.