hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.53k stars 377 forks source link

E5108: Cursor position outside buffer #1693

Open ashfinal opened 10 months ago

ashfinal commented 10 months ago

FAQ

Announcement

Minimal reproducible full config

        formatting = {
          format = function(entry, vim_item)
            vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind], vim_item.kind)
            vim_item.menu = ({
              buffer = "[ ]",
              luasnip = "[󱉥 ]",
              nvim_lsp = "[ ]",
              copilot = "[ ]",
            })[entry.source.name]
            vim_item.abbr = string.gsub(vim_item.abbr, "%(.+%)", "")
            return vim_item
          end
        },
        mapping = {
          ["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
          ["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
          ["<C-n>"] = cmp.mapping({
            i = function(fallback)
              if cmp.visible() then
                cmp.select_next_item( { behavior = cmp.SelectBehavior.Select } )
              else
                fallback()
              end
            end,
            c = function(fallback)
              if cmp.visible() then
                cmp.select_next_item( { behavior = cmp.SelectBehavior.Insert } )
              else
                fallback()
              end
            end,
          }),
          ["<C-p>"] = cmp.mapping({
            i = function(fallback)
              if cmp.visible() then
                cmp.select_prev_item( { behavior = cmp.SelectBehavior.Select } )
              else
                fallback()
              end
            end,
            c = function(fallback)
              if cmp.visible() then
                cmp.select_prev_item( { behavior = cmp.SelectBehavior.Insert } )
              else
                fallback()
              end
            end,
          }),
          ["<Tab>"] = cmp.mapping(function(fallback)
            if cmp.visible() and cmp.get_active_entry() then
              cmp.confirm({ select = false })
            elseif luasnip.expand_or_locally_jumpable() then
              luasnip.expand_or_jump()
            else
              fallback()
            end
          end, { "i", "s" }),
          ["<S-Tab>"] = cmp.mapping(function(fallback)
            if luasnip.jumpable(-1) then
              luasnip.jump(-1)
            else
              fallback()
            end
          end, { "i", "s" }),
          ["<C-e>"] = cmp.mapping(cmp.mapping.abort(), { "i", "c" }),
          ["<CR>"] = cmp.mapping({
            i = function(fallback)
              if cmp.visible() and cmp.get_active_entry() then
                cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
              else
                fallback()
              end
            end,
          }),
        },
      local letsdebug = require("cmp.utils.debug")
      letsdebug.flag = true

Description

It's hard to reproduce, but I'm desperate... With zbirenbaum/copilot-cmp, the probility is quite high. I set debug.flag to true, unfortunately I can't read it(see log below).

Steps to reproduce

nvim myfile.txt(blank) input we can do m, <C-n> <C-p> for several times, then <CR>

cmp Debug :mess >>> CursorMovedI >>> TextChangedI ctx: `we can` changed copilot^Irequest^I6^I{ triggerKind = 3 } >>> CursorMovedI >>> TextChangedI ctx: `we can ` changed copilot^Irequest^I7^I{ triggerKind = 3 } >>> CursorMovedI >>> TextChangedI ctx: `we can d` changed copilot^Irequest^I8^I{ triggerKind = 3 } luasnip^Irequest^I8^I{ triggerKind = 1 } buffer^Irequest^I8^I{ triggerKind = 1 } luasnip^Iretrieve^I9 buffer^Iretrieve^I2 >>> CursorMovedI >>> TextChangedI ctx: `we can do` changed copilot^Irequest^I9^I{ triggerKind = 3 } copilot^Iretrieve^I2 >>> CursorMovedI >>> TextChangedI ctx: `we can do ` changed copilot^Irequest^I10^I{ triggerKind = 1 } >>> CursorMovedI >>> TextChangedI ctx: `we can do m` changed copilot^Irequest^I11^I{ triggerKind = 3 } luasnip^Irequest^I11^I{ triggerKind = 1 } buffer^Irequest^I11^I{ triggerKind = 1 } luasnip^Iretrieve^I9 buffer^Iretrieve^I6 copilot^Iretrieve^I2 entry.confirm^I{ cmp = { kind_hl_group = "CmpItemKindCopilot", kind_text = "Copilot" }, copilot = true, documentation = { kind = "markdown", value = "```text\nwe can do more than just talk about it.\n```" }, dup = 0, filterText = "we can do more than just talk about it.", kind = 1, label = "we can do more than just talk about it.", textEdit = { insert = <1>{ ["end"] = { character = 39, line = 0 }, start = { character = 0, line = 0 } }, newText = "we can do more than just talk about it.\n", replace = } } E5108: Error executing lua ...shfinal/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:483: Cursor position outside buffer stack traceback: [C]: in function 'nvim_win_set_cursor' ...shfinal/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:483: in function <...shfinal/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:434> ...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...ocal/share/nvim/lazy/nvim-cmp/lua/cmp/utils/feedkeys.lua:45>

Expected behavior

Complete without error.

Actual behavior

E5108: Error executing lua ...shfinal/.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:483: Cursor position outside buffer

Additional context

No response