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

bug: Keys are not showed during vim.fn.input() when called from Visual mode #347

Closed
3 tasks done
echasnovski opened this issue Feb 3, 2023 · 2 comments · Fixed by #349 or #639
Closed
3 tasks done

bug: Keys are not showed during vim.fn.input() when called from Visual mode #347

echasnovski opened this issue Feb 3, 2023 · 2 comments · Fixed by #349 or #639
Labels
bug Something isn't working

Comments

@echasnovski
Copy link

Did you check docs and existing issues?

  • I have read all the noice.nvim docs
  • I have searched the existing issues of noice.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.9.0-dev-857+g2c5906b55

Operating system/version

EndeavourOS Linux x86_64 (6.1.8-arch1-1)

Describe the bug

When vim.fn.input() is called during Visual mode, it doesn't show user's pressed keys while still processing them correctly.

Steps To Reproduce

  1. Create the following mappings:
-- Doesn't show input characters, but registers them (`_G.input_result` is as expected)
-- Doesn't work even if `vim.o.showmode = false`
-- Without 'noice.nvim' works as expected in command line
vim.keymap.set('x', '<M-x>', [[<Cmd>lua _G.input_result = vim.fn.input({ prompt = 'Enter: ' })<CR>]])
vim.keymap.set('x', '<M-f>', function() _G.input_result = vim.fn.input({ prompt = 'Enter: ' }) end)

-- Works as expected
vim.keymap.set('n', '<M-n>', [[<Cmd>lua _G.input_result = vim.fn.input({ prompt = 'Enter: ' })<CR>]])
  1. In Visual mode press <M-x>. Type abcd. It doesn't appear in popup window.
    Press <CR>. All key presses do appear for a brief moment.
    Type :lua print(_G.input_result). It should show abcd, as expected.
  2. In Visual mode press <M-f>. Type efgh. The result is the same with updated value of _G.input_result.
  3. In Normal mode press <M-n>. Type ijkl. It does appear in popup window and value of _G.input_result is updated.

Expected Behavior

Any user's key press should immediately be shown in popup window (as when in command line without 'noice.nvim').

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/noice.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")

-- Doesn't show input characters, but registers them (`_G.input_result` is as expected)
-- Doesn't work even if `vim.o.showmode = false`
-- Without 'noice.nvim' works as expected in command line
vim.keymap.set('x', '<M-x>', [[<Cmd>lua _G.input_result = vim.fn.input({ prompt = 'Enter:' })<CR>]])
vim.keymap.set('x', '<M-f>', function() _G.input_result = vim.fn.input({ prompt = 'Enter:' }) end)

-- Works as expected
vim.keymap.set('n', '<M-n>', [[<Cmd>lua _G.input_result = vim.fn.input({ prompt = 'Enter:' })<CR>]])
@echasnovski
Copy link
Author

It might be the reason behind #346.

@folke
Copy link
Owner

folke commented Feb 6, 2023

Sorry for the late reply.

The issue was that mode() returns V when vim.fn.input is called when in visual mode. And there's no vc special mode for this case.

Should be fixed now. Whenever the cmdline is open, Noice will always assume blocking mode.

Thank you for the detailed bug report!

willothy pushed a commit to willothy/noice.nvim that referenced this issue Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants