jackMort / ChatGPT.nvim

ChatGPT Neovim Plugin: Effortless Natural Language Generation with OpenAI's ChatGPT API
Apache License 2.0
3.71k stars 310 forks source link

`Error..Expected Lua number` when closing window before ChatGPT finishes writing #325

Closed aaronik closed 8 months ago

aaronik commented 10 months ago

First of all, I love this plugin, it's my favorite IDE / AI integration so far. I use it daily. Thank you so much for your work!

The issue

The one real issue I face that slows me down, is that if I close the ChatGPT or ChatGPTEditWithInstructions window while the AI is still writing back, then I receive this error:

Error executing vim.schedule lua callback: ...e/nvim/lazy/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:551: Expected Lua number                                                                              
stack traceback:
        [C]: in function 'nvim_buf_del_extmark'
        ...e/nvim/lazy/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:551: in function 'display_input_suffix'
        ...e/nvim/lazy/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:57: in function <...e/nvim/lazy/ChatGPT.nvim/lua/chatgpt/flows/chat/base.lua:55>
Press ENTER or type command to continue

I press ENTER or q or any key and the error window closes, but comes back in a couple hundred milliseconds later. They will stack when I hit ENTER as well:

image

Current workaround

The only real way I've found to avoid the error is let ChatGPT finish writing before closing the window. Sometimes this is fine, but sometimes I get what I need from ChatGPT and don't need to listen to the rest of what it says. In that instance I'd like to be able to move quickly and close the window, using what I opened it for.

I've been keeping my eye on the repo, seeing if anybody had posted this, but I so far haven't been able to find anything. That's surprising to me - does this happen to you as well? If not, I wonder what might be happening with my setup that's leading to this.