max397574 / better-escape.nvim

Map keys without delay when typing
GNU General Public License v3.0
629 stars 19 forks source link

fix: possibly unwanted keymap behaviour #84

Closed jumpyjacko closed 3 months ago

jumpyjacko commented 3 months ago

Hello!

I had the same (or similar) issue as in #68 but I thought that this is still unwanted behaviour, even if it is the intended behaviour. This PR changes the way the mapping input is handled so that even if there is a conflicting keymap, like using <Esc> for closing a completion window, it will still kick you back to Normal mode.

Below is a demonstration of the behaviour without the fix. https://youtu.be/rX_D1S7NZCI

Below is a demonstration of the behaviour with the fix. https://youtu.be/UZS-a6Zsj1U

I'm unsure if this is the best solution because I am not experienced with lua and [nvim_feedkeys](https://neovim.io/doc/user/api.html#nvim_feedkeys()) is a blocking call instead of [nvim_input](https://neovim.io/doc/user/api.html#nvim_input())'s non-blocking asynchronous call.

Extra note: I observed that the default keymap "jk" worked perfectly fine with default_keymaps = true, so it may instead be an issue with how custom keymaps are handled.

max397574 commented 3 months ago

thank you for your contribution I just don't know if I actually want this

Because some users might expect that the mapped keys get used perhaps the few ones who don't should use a custom function to fix this

I will have to think about this and decide later

max397574 commented 3 months ago

We'll merge this as is