Open deeperlearner opened 4 months ago
I don't want to fix this because I don't know exactly how it was supposed to work, but this error is because the lines table being passed to nvim_buf_set_lines
sometimes has something at the zeroth index. This has something to do with CiRound:Render
interacting getRandomInsertionLocation
but it's not clear to me how this was actually supposed to work (for instance I can't tell if gameLineCount
is supposed to include the instructions or not, at 20 it's too low to include them but linesAfterInstructions = gameLineCount - #instructions
seems to imply that they are included).
On the plus side I learned a little about Lua.
I replace the vim.api.nvim_buf_set_lines(self.bufh, idx, idx + #lines, false, lines)
line with this small snippet that shifts by 1 if the table starts from 0.
local new_lines = {}
if lines[0] ~= nil then
new_lines[#new_lines+1] = lines[0]
for i=1,#lines do
new_lines[#new_lines+1] = lines[i]
end
else
new_lines = lines
end
vim.api.nvim_buf_set_lines(self.bufh, idx, idx + #new_lines, false, new_lines)
It's pretty dirty but it works.
The error come out sometimes in the ci{ game:
Neovim Version: v0.9.5