copilot.lua icon indicating copy to clipboard operation
copilot.lua copied to clipboard

Accept suggestion results in Range too large error

Open RobinClowers opened this issue 1 year ago • 5 comments

I just set this plugin up, and tried the simplest thing.

function sum(a: number, b: number) {
	// here I invoked the next function with <M-]>
}

It generated the suggestion just fine, but when I tried to accept it with <M-l>, I get this error:

E5108: Error executing lua: Vim:E945: Range too large in character class
stack traceback:
        [C]: in function 'substitute'
        ...ocal/share/nvim/plugged/copilot.lua/lua/copilot/util.lua:300: in function 'strutf16len'
        ...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:463: in function 'fn'
        ...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:32: in function 'with_client'
        ...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:460: in function <...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:445>

I suspect I'm doing something wrong here, since this plugin is working for other folks. I'm using vim-plug and calling setup from a vimrc file, like this:

call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
" ... other plugins

Plug 'zbirenbaum/copilot.lua'

call plug#end()

" Initialize github copilot
lua require('copilot').setup({})

RobinClowers avatar Nov 29 '23 22:11 RobinClowers

What's the output of :Copilot version?

MunifTanjim avatar Dec 01 '23 12:12 MunifTanjim

Neovim 0.9.1
copilot.vim 1.12.1
copilot.lua 3665ed0f3ef3ad68673df7195789d134d0d1fdb0
copilot/dist/agent.js 1.138.0
Node.js 18.17.1

RobinClowers avatar Dec 01 '23 22:12 RobinClowers

FYI I just upgraded neovim to 0.9.4 and I still get the same result.

RobinClowers avatar Dec 02 '23 01:12 RobinClowers

May be related, but I'm getting this error happens to me whenever I try to accept a suggestion:

[Copilot] failed to notify_accepted for:                         kill = "<C-c>",
Error: Vim:E945: Range too large in character class

The text is still entered into the buffer, but that error comes up every time I accept that suggestion.

Here is my version info:

Neovim 0.9.4
copilot.vim 1.12.1
copilot.lua 38a41d0d78f8823cc144c99784528b9a68bdd608
copilot/dist/agent.js 1.138.0
Node.js 21.4.0

And my configuration with lazy.nvim:

return {
    {
        "zbirenbaum/copilot.lua",
        cmd = "Copilot",
        event = "InsertEnter",
        config = function ()
            require('copilot').setup({
                  panel = {
                    enabled = false,
                },
                suggestion = {
                    enabled = true,
                    auto_trigger = true,
                    debounce = 75,
                    keymap = {
                        accept = "<C-k>",
                    },
                },
                filetypes = {
                    commit = false,
                    cvs = false,
                    git = false,
                    gitcommit = false,
                    gitrebase = false,
                    gitsendmail = false,
                    help = false,
                    hgcommit = false,
                    markdown = false,
                    md = false,
                    mkd = false,
                    svn = false,
                    tex = false,
                    text = false,
                    yaml = false,
                },
            })
        end
    }
}

mr-mustash avatar Dec 13 '23 20:12 mr-mustash

Same here

Neovim 0.9.5
copilot.vim 1.13.0
copilot.lua b03617a6dc4bc88b65ab5deac1631da9a9c2dcaf
copilot/dist/agent.js 1.141.0
Node.js 21.3.0

sakithb avatar Jan 28 '24 16:01 sakithb