lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.07k stars 102 forks source link

Attempt to perform arithmetic on a nil value #814

Closed AnthonyCalandra closed 8 months ago

AnthonyCalandra commented 8 months ago

Problem

Scrolling through some files I get stopped with the following error message:

Error detected while processing CursorMoved Autocommands for "*":
Error executing lua callback: ...azyVim-data/lazy/indent-blankline.nvim/lua/ibl/hooks.lua:225: attempt to perform arithmetic on a nil value
stack traceback:
        ...azyVim-data/lazy/indent-blankline.nvim/lua/ibl/hooks.lua:225: in function 'fn'
        ...LazyVim-data/lazy/indent-blankline.nvim/lua/ibl/init.lua:304: in function 'refresh'
        ...LazyVim-data/lazy/indent-blankline.nvim/lua/ibl/init.lua:128: in function 'debounced_refresh'

        ...LazyVim-data/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'

        ...Vim-data/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:27: in function <...Vim-data/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26>

I suspect maybe the attempted fix here of another issue is the problem: https://github.com/lukas-reineke/indent-blankline.nvim/pull/809

Let me know if there is anything I can do to help. Thanks for the plugin :)

Steps to reproduce

Start nvim and open the file you wish to edit. Start scrolling until an error message appears.

Here's an example file I was editing that showed the problem:

// https://quuxplusone.github.io/blog/2018/08/11/the-auto-macro/

#pragma once

template <class L>
class AtScopeExit
{
    L& m_lambda;

public:
    AtScopeExit(L& action) : m_lambda(action) {}
    ~AtScopeExit()
    {
        m_lambda();
    }
};

#define TOKEN_PASTEx(x, y) x##y
#define TOKEN_PASTE(x, y)  TOKEN_PASTEx(x, y)

#define Auto_INTERNAL1(lname, aname, ...) \
    auto lname = [&]() { __VA_ARGS__; };  \
    AtScopeExit<decltype(lname)> aname(lname);

#define Auto_INTERNAL2(ctr, ...)                     \
    Auto_INTERNAL1(TOKEN_PASTE(Auto_func_, ctr),     \
                   TOKEN_PASTE(Auto_instance_, ctr), \
                   __VA_ARGS__)

#define AT_SCOPE_EXIT(...) Auto_INTERNAL2(__COUNTER__, __VA_ARGS__)

Line 21 is an example of a line that triggers the error for me.

Expected behavior

There are no errors.

Neovim version (nvim -v)

NVIM v0.9.2

Danielkonge commented 8 months ago

This error seems similar to the error I noticed in https://github.com/lukas-reineke/indent-blankline.nvim/pull/743#discussion_r1374987678, but I don't really see what the error on line 255 is, so I am not sure if it is caused by the same thing.

If you replace end_line:find "%S" - 1 with #end_line - 1 in hooks.lua do you still get the error? (Note: this will not be the correct fix, since it doesn't capture what we want, I am just unsure if this part is what is causing the error?)

omani commented 8 months ago

same issue for me. errors while scrolling through rust code.

lukas-reineke commented 8 months ago

Released a fix

sorry for the delay, had some time off, and then we had the earthquake and tsunami

calebdw commented 8 months ago

@lukas-reineke, I'm still getting a similar error:

Error detected while processing CursorMoved Autocommands for "*":
Error executing lua callback: ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: invalid key: virt_text_repeat_linebreak
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: in function 'refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:128: in function 'debounced_refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'
        ...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:27: in function <...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26>
Danielkonge commented 8 months ago

@lukas-reineke, I'm still getting a similar error:

Error detected while processing CursorMoved Autocommands for "*":
Error executing lua callback: ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: invalid key: virt_text_repeat_linebreak
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:478: in function 'refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:128: in function 'debounced_refresh'
        ...l/share/nvim/lazy/indent-blankline.nvim/lua/ibl/init.lua:144: in function 'debounced_refresh'
        ...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:27: in function <...are/nvim/lazy/indent-blankline.nvim/lua/ibl/autocmds.lua:26>

That's not a similar error, that is a the same as #813.

You need to either use stable (0.9.5 is the latest, but I think 0.9.4 and older also work) or a newer version of 0.10 (not much more than a week old).