Skip to content

Stack overflow in nvim_replace_termcodes #441

@cameron1024

Description

@cameron1024

Make sure you have done the following

  • I have updated to the latest version of blink.cmp
  • I have read the README

Bug Description

I'm using lean.nvim with the Lean programming language, and geting an error when I press "enter", which is bound because I'm using keymap.preset = "enter".

This only triggers after typing \ in insert mode, which is used to insert special characters (Lean uses lots of mathematical symbols, so typing \alpha in insert mode followed by a space will insert a α in the buffer. I'm not 100% sure where this is coming from (perhaps the LSP) but doesn't seem to have anything to do with blink.

Once I've typed \ at all, the error persists whenever I press enter in insert mode to enter a newline. If I press enter to accept a suggestion, the error doesn't trigger. I can enter a newline with <C-o>o without issues. Typing \ in a non-lean buffer doesn't trigger this behaviour. The error seems to be contained to the buffer that had the \ typed in it - opening a new lean buffer and pressing enter correctly enters newlines. Running Lazy reload blink.cmp doesn't fix the buffer.

The exact error I get is:

E5108: Error executing lua: stack overflow
stack traceback:
        [C]: in function 'nvim_replace_termcodes'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:15: in function 'get_non_blink_mapping_for_key'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:25: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function 'callback'
        ...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fallback.lua:38: in function <...re/nvim/lazy/blink.cmp/lua/blink/cmp/keymap/fa
llback.lua:24>

I got this by triggering the error then copying from the popup in vim itself, but if there's a better way to grab these stack traces let me know and I'll be happy to capture it properly.

Thanks 😁

Relevant configuration

keymap = {
  preset = "enter",
}

neovim version

NVIM v0.11.0-dev Build type: Release LuaJIT 2.1.1713773202

blink.cmp version: branch, tag, or commit

85f318b

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions