David-Kunz / gen.nvim

Neovim plugin to generate text using LLMs with customizable prompts
The Unlicense
1.15k stars 87 forks source link

Error with `replace=true` on empty line #96

Closed Robzz closed 4 months ago

Robzz commented 4 months ago

Hi there, thanks for the great plugin :+1:

I noticed an error when a prompt uses replace = true and using it in normal mode on an empty line: nvim/lazy/gen.nvim/lua/gen/init.lua:336: Invalid 'end_col': out of range.
I think the end_pos[3] is the problem and should be end_pos[3] - 1 ? Admittedly I know nothing about the nvim API so I don't know if there's a good reason for it or if it's just a mistake, but making the change it in my local copy seems to do the trick. So does adding a single space to the line before triggering the completion.

Let me know if you'd like a PR.

KIMGEONUNG commented 4 months ago

Same issue to me, and @Robzz's solution works in my case.

alejandrorusso commented 4 months ago

Same issue here!

/root/.local/share/nvim/lazy/gen.nvim/lua/gen/init.lua:336: Invalid 'end_col': out of range
stack traceback:
^I[C]: in function 'nvim_buf_set_text'                                                                                      
^I/root/.local/share/nvim/lazy/gen.nvim/lua/gen/init.lua:336: in function 
</root/.local/share/nvim/lazy/gen.nvim/lua/gen/init.lua:317> 
David-Kunz commented 4 months ago

Thanks for the info @Robzz , I'll check!

David-Kunz commented 4 months ago

Fixed, thanks again, @Robzz !