NStefan002 / screenkey.nvim

Screencast your keys in Neovim
MIT License
288 stars 5 forks source link

Screen stops working altogether when i di" #36

Closed XavierChanth closed 1 month ago

XavierChanth commented 1 month ago

Problem

I am using mini.ai which I think may part of the problem, I'm not very knowledgeable in how vim objects behave, let alone custom ones.

Snapshot of loaded dependencies when the problem occurred:

   Loaded (41)
    ● catppuccin 0.8ms colorscheme catppuccin-frappe  LazyVim
    ● clangd_extensions.nvim 0.52ms 󰢱 clangd_extensions.cmp_scores  nvim-cmp
    ● cmp-buffer 12.49ms  nvim-cmp
    ● cmp-nvim-lsp 1.49ms  nvim-cmp
    ● cmp-path 0.91ms  nvim-cmp
    ● cmp_luasnip 1.15ms  nvim-cmp
    ● dashboard-nvim 0.64ms  start
    ● flash.nvim 0.94ms  VeryLazy
    ● friendly-snippets 16.44ms  LuaSnip
    ● git-worktree.nvim 9.21ms 󰢱 telescope._extensions.git_worktree  telescope.nvim
    ● gitsigns.nvim 8.33ms  LazyFile
    ● indent-blankline.nvim 4.88ms  LazyFile
    ● last-color.nvim 0.47ms  LazyVim
    ● lazy.nvim 22.31ms  init.lua
    ● lazydev.nvim 1.65ms  lua
    ● LazyVim 5.11ms  start
    ● lualine.nvim 14.75ms  VeryLazy
    ● LuaSnip 18.91ms 󰢱 luasnip  cmp_luasnip
    ● mason-lspconfig.nvim 0.19ms  nvim-lspconfig
    ● mason.nvim 23.55ms  nvim-lspconfig
    ● mini.ai 0.78ms  VeryLazy
    ● mini.icons 4.93ms 󰢱 mini.icons  LazyVim
    ● noice.nvim 1.59ms  VeryLazy
    ● nui.nvim 0.06ms 󰢱 nui.object  noice.nvim
    ● nvim-cmp 20.62ms  InsertEnter
    ● nvim-lint 0.84ms  LazyFile
    ● nvim-lspconfig 48.39ms  LazyFile
    ● nvim-notify 1.37ms 󰢱 notify  noice.nvim
    ● nvim-treesitter 3.77ms  VeryLazy
    ● nvim-treesitter-textobjects 4.93ms  VeryLazy
    ● nvim-ts-autotag 3.15ms  LazyFile
    ● oil.nvim 3.19ms 󰢱 oil.config  lualine.nvim
    ● persistence.nvim 0.53ms  start
    ● plenary.nvim 0.47ms 󰢱 plenary.window.float  git-worktree.nvim
    ● screenkey.nvim 12.26ms  Screenkey
    ● telescope-fzf-native.nvim 8.13ms  telescope.nvim
    ● telescope.nvim 23.96ms 󰢱 telescope  util.git_worktree
    ● todo-comments.nvim 3.01ms  LazyFile
    ● trouble.nvim 1.48ms 󰢱 trouble  lualine.nvim
    ● ts-comments.nvim 1.14ms  VeryLazy
    ● which-key.nvim 0.55ms  VeryLazy

Steps to reproduce

See problem above

Screenkey log output

The log is empty, even when I run an instance of nvim without having done di"

Expected behavior

No response

Neovim version (nvim -v)

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713773202

Terminal name/version

wezterm 20240203-110809-5046fc22

NStefan002 commented 1 month ago

Hi, sorry for the late reply. I don't use mini.ai, I installed it and can replicate the issue, but currently don't know how to solve this.

XavierChanth commented 1 month ago

Hi, sorry for the late reply. I don't use mini.ai, I installed it and can replicate the issue, but currently don't know how to solve this.

NP, I would love it if I could use your plugin, but I'll have to wait until I can dig in to the code and figure out the problem. Maybe an expert like @echasnovski can help? (Sorry if the ping is troublesome) 🙏🏻

NStefan002 commented 1 month ago

Mr. Echasnovski already helped out a lot (I opened up an issue in mini.nvim repo and he supplied me with some great tips and information) and I think I can solve this bug.

It'll just have to wait a day or two since I'm busy now, thanks for understanding.

NStefan002 commented 1 month ago

@XavierChanth I pushed the fix to this problem to the dev branch. Can you test it? I can no longer produce the bug when using mini.ai.

echasnovski commented 1 month ago

Just to clarify the message in 75b44c5ddab5dd16440bfaa82075475d019e509d. It is not solely getcharstr() that causes problems, but its usage inside expression mappings:

XavierChanth commented 1 month ago

@XavierChanth I pushed the fix to this problem to the dev branch. Can you test it? I can no longer produce the bug when using mini.ai.

Works great! Thanks for the quick response

NStefan002 commented 1 month ago

Just to clarify the message in 75b44c5. It is not solely getcharstr() that causes problems, but its usage inside expression mappings:

  • There is a list of things that are not allowed to do inside expression mappings (see :h :map-expression).
  • getcharstr() "blocks" the editor in the expression mapping state while allowing other scheduled functions to be executed. If those scheduled functions do something that is not allowed inside expression mapping, there is an error.
  • Error inside on_key() callback clears said callback (i.e. it stop being executed).

Thank you for all the help! I already went through everything you mentioned in the mini.ai issue I opened, but I'll update the commit message for additional clarity.

NStefan002 commented 1 month ago

Works great! Thanks for the quick response

Thank you for testing! I merged this fix, it's now available in the 2.3.1 release.