Closed XanX3601 closed 8 months ago
I tried a few things to fix the error and figure out that, on file lua/null-ls/helpers/diagnostics.lua
, at line 72, the function vim.str_byteindex
is used to get something.
By printing the arguments given to this function, I saw that it could be given a string of length $n$ and an index $n+1$ (depending on the string).
By applying the following code:
local col = tonumber(entries["col"])
col = math.min(col, string.len(content_line))
local byte_index_col = vim.str_byteindex(content_line, col)
I obtain the desire behavior. Meaning that there is no crash and the syntax error is displayed correctly.
I don't know if it is the right strategy to resolve this bug or if the problem comes from somewhere else in the code but this temp fix is enough for me to get the desire behaviour.
I'd prefer not to open a PR by myself as it looks like it is a quick fix and I do not have a dev env installed to test it.
I will try to answer questions if any
Does this happen with providers other than ruff? I can't recreate this with my current set up. (I don't use ruff).
I just tried using flake8 and the issue is the same. I just changed ruff
by flake8
in the minimal_init.lua
This is happening with vint as well
I'll see if I can dedicate some time to this over the next few days.
[null-ls] failed to run generator: ...im/lazy/none-ls.nvim/lua/null-ls/helpers/diagnostics.lua:71: index out of range
Facing the same issue with similar setup
[null-ls] failed to run generator: ...im/lazy/none-ls.nvim/lua/null-ls/helpers/diagnostics.lua:71: index out of range
Facing the same issue with similar setup
See my temporary fix above if you need in the meantime.
Picked https://github.com/nvimtools/none-ls.nvim/issues/51#issuecomment-1867956063. Please report any further crashes here if it still occurs.
I tried a few things to fix the error and figure out that, on file
lua/null-ls/helpers/diagnostics.lua
, at line 72, the functionvim.str_byteindex
is used to get something. By printing the arguments given to this function, I saw that it could be given a string of length n and an index n+1 (depending on the string).By applying the following code:
local col = tonumber(entries["col"]) col = math.min(col, string.len(content_line)) local byte_index_col = vim.str_byteindex(content_line, col)
I obtain the desire behavior. Meaning that there is no crash and the syntax error is displayed correctly.
I don't know if it is the right strategy to resolve this bug or if the problem comes from somewhere else in the code but this temp fix is enough for me to get the desire behaviour.
I'd prefer not to open a PR by myself as it looks like it is a quick fix and I do not have a dev env installed to test it.
I will try to answer questions if any
This also fixed the issue for me. Why don’t you open a PR for this? As it still seem to be there in newer versions
I already applied that fix a while ago, so this might be a culprit elsewhere.
I confirm what @mochaaP just said, they commited the fix I suggested and, once I updated the package through :PackerSync
, the crash did not occur anymore.
Easy way to test it to reproduce the steps with a clean config as described in the issue.
I did not say thank you @mochaaP at the time so thank you for fixing the crash 😄
FAQ
Issues
Neovim Version
0.9.4
Dev Version?
Operating System
Macos
Minimal Config
Steps to Reproduce
minimal_init.lua
provided:The crash should occur at step 3 The message can be seen using the neovim command
:messages
Reproducibility Check
minimal_init.lua
template and that my issue is reproducible by runningnvim --clean -u minimal_init.lua
and following the steps above.Expected Behavior
No crash and display syntax error
Actual Behavior
Crash of none-ls and it does not restart until neovim is restarted. It will keep crashing till the syntax error is fine
Debug Log
[WARN Fri Dec 22 19:08:49 2023] /tmp/nvim/site/pack/packer/start/none-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...r/start/none-ls.nvim/lua/null-ls/helpers/diagnostics.lua:71: index out of range
Help
No
Implementation Help
No response
Requirements