Closed unphased closed 1 month ago
This can no longer happen with the rewrite v3 https://github.com/folke/which-key.nvim/pull/624
oh, it actually does this as well :) Will see if there's something I can do to fix this. Like close which-key after a certain timeout.
Actually, great idea on FocusLost. I'll just close which-key in that case
Dope... I take it I'll have to wait/upgrade to v3 and then nuke the code I just described above? I'll make a note to self to do that but i suspect the code i described (auto keyfeed Esc on FocusLost) is going to be mostly harmless. Though not being able to select something and unfocus nvim would be a drawback. Oh! Oh! ok i'm going to make my code not feed Esc if mode is visual! Sick.
Did you check the docs?
Is your feature request related to a problem? Please describe.
I still think there may already be a way to do this. But I am too dumb to figure it out.
Use case:
d
. Click out of terminal window (or tmux pane). Come back 5 minutes later by clicking in the neovim window. Surprise! many characters are deleted because of some stray keyboard input from a while ago.if mode:find('^no') or mode:find('^o') or which_key_open then
check, as a pending keystroke in whichkey shows up in neovim asn
normal mode.Describe the solution you'd like
a way to ask which-key if its popup is currently active
Describe alternatives you've considered
may be able to add my own tracking state of whichkey popup being open if i can set hooks on the events of the popup being opened and closed.
Another workaround is to introduce a sane timeout to both operator pending state (which may be the default, i'm not even sure how to end up in operator pending state when which-key is being used...) and which-key to have a cancel out timeout. I just kinda wanna avoid this as being possibly impractical, because sometimes I really do want to read the whichkey popup for a whole minute to review my keybinds.
Another alternative would be to just feedkey
<Esc>
(viavim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
(attribution: Claude 3.5 Sonnet)) on FocusLost no matter what. I think I will just do this for now. However it is not ideal, as it means I can no longer leave a nvim unfocused in insert mode ready to take a paste or something, and cannot have selection state remain in an unfocused nvim. But I could get used to that maybe.Additional context
No response