Closed thehunmonkgroup closed 1 year ago
https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L172 assumes that line is a table.
line
However, I'm seeing instances when Neovim is opened via a pipe (in my case via vipe) that https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L31-L33 returns true, nil, and in this case it's throwing an index error at https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L172
vipe
true, nil
I'm not sure if this is a bug in vim.api.nvim_buf_get_lines() or something peculiar to running Neovim through pipes, but changing https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L172 to this:
vim.api.nvim_buf_get_lines()
if not line or #line == 0 then
Fixes the issue for me.
This change will not affect the existing logic, and seems reasonable defensive programming, especially given the issue I'm addressing.
@thehunmonkgroup thanks for leaving this breadcrumb - can confirm I had the same issue and that your proposed fix also appears to have resolved the issue for me.
https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L172 assumes that
line
is a table.However, I'm seeing instances when Neovim is opened via a pipe (in my case via
vipe
) that https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L31-L33 returnstrue, nil
, and in this case it's throwing an index error at https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L172I'm not sure if this is a bug in
vim.api.nvim_buf_get_lines()
or something peculiar to running Neovim through pipes, but changing https://github.com/Darazaki/indent-o-matic/blob/master/lua/indent-o-matic.lua#L172 to this:Fixes the issue for me.
This change will not affect the existing logic, and seems reasonable defensive programming, especially given the issue I'm addressing.