David-Kunz / gen.nvim

Neovim plugin to generate text using LLMs with customizable prompts
The Unlicense
992 stars 64 forks source link

fix: Output window remains blank #33

Closed macukadam closed 8 months ago

macukadam commented 8 months ago

Hey David,

I had this problem with a blank screen (https://github.com/David-Kunz/gen.nvim/issues/32#issue-2000361462).

I don't know exactly what causes it, but I've debugged my way around and found that setting pty to true solves the issue at jobstart. Although, the output ends with carriage returns like this:

Some text^M Some other text^M Bla bla bla^M bla bla bla bla^M

So I've added this piece of code to remove it:

if opts.pty then
   -- Remove carriage returns from each line
    for i, line in ipairs(data) do
       data[i] = line:gsub('\r', '')
    end
end