max397574 / better-escape.nvim

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

`jk` works, but `kjk` does not #69

Closed nullromo closed 3 months ago

nullromo commented 3 months ago

Problem

I'm not sure if this is intentional, but after inserting a k, the jk functionality breaks. Here is a demo.

https://github.com/max397574/better-escape.nvim/assets/8991581/8acd13c0-5bb8-46ed-b4ee-3c3fc6c9ca0d

So after I type the letter k and then I try to leave insert mode, I just end up with a jk in the buffer.

Expected behavior

I do not get this problem when I use

" vim
inoremap jk <ESC>

or

-- lua
vim.keymap.set('i', 'jk', '<ESC>')

I would expect this plugin to behave identically to these mappings. So if I press kjk from insert mode, then I would expect to be in normal mode with a k in the buffer.

max397574 commented 3 months ago

that is indeed a but really weird is that I can't reproduce it with my own config but I can with a minimal config

I'll investigate this

edit: this got introduced with https://github.com/max397574/better-escape.nvim/pull/67 I'll see if I can fix it

max397574 commented 3 months ago

after some more debugging I can reproduce this only if I press the jk right after the k. If I wait for some time it works again. Can you confirm that you also have this behavior?

max397574 commented 3 months ago

@Jint-lzxy @Sam-programs any of you two have an idea how we could fix this issue?

nullromo commented 3 months ago

Can you confirm that you also have this behavior?

Yes, that's right.

Note that vim's default value for timeoutlen is 1000 ms.

Sam-programs commented 3 months ago

any of you two have an idea how we could fix this issue?

Yeah ... I forgot to log the key in a code path. See #70. Sorry!

nullromo commented 3 months ago

Looks good on my end. Thanks!