chomosuke / typst-preview.nvim

Low latency typst preview for Neovim
GNU General Public License v3.0
254 stars 16 forks source link

Using keys other than escape, like `jk` or `jj` to <Esc> always leave the first character behind #21

Open westernwontons opened 7 months ago

westernwontons commented 7 months ago

Steps to reproduce:

  1. Bind jk to esc with map jk n j * v:count == 0 ? 'gj' : 'j'
  2. Open a typst document
  3. Type anything
  4. Press jk
  5. j is left behind
chomosuke commented 6 months ago

Hello, sorry for the late reply and thanks for pointing this out.

It seems that I can not reproduce this issue. I have ,. imap to <Esc> as well and have never experienced similar issue. I am not sure how are you binding jk to esc. Following the command you provided: :map jk n j * v:count == 0 ? 'gj' : 'j' I can't seem to get jk mapped to esc. Do you have more details on how you're mapping jk to <Esc>? I am assuming your mapping it in insert mode.

westernwontons commented 6 months ago

The plugin that I'm using is https://github.com/max397574/better-escape.nvim with the following config:

{
    "max397574/better-escape.nvim",
    opts = function(_, opts)
        opts.mapping = { "jk", "jK" }
        opts.timeout = 150
        return opts
    end
}

Exiting with indeed doesn't reproduce this issue for me either

chomosuke commented 6 months ago

Hello there,

I've installed better-escape.nvim but I still cannot reproduce your issue.

If you'd like, you can try to debug the issue yourself. One way to solve the issue could be to add more events to line 46 of lua/typst-preview/events/autocmds.lua.