Open arindas opened 1 year ago
Thanks for this, it fixed the same issue I had 👍
Can confirm, this fixes the issue
@simrat39
I've pulled this in https://github.com/MunifTanjim/rust-tools.nvim/tree/patched
I wasn't aware of the strict indexing feature. Thank you. Is there anything actionable from my end?
You can update this PR with the suggestion. But until @simrat39 gets back, nobody can merge this.
In the meantime, if you want to use rust-tools.nvim
with a few fixes from various PRs, you can use my patched
branch: https://github.com/MunifTanjim/rust-tools.nvim/commits/patched
I also start forking at https://github.com/ryo33/rust-tools.nvim-nightly-. But I don't recommend this to most people because I don't mind my fork being broken by eagerly merging many pull-requests without my own review or compatibility check.
The last parameter of
vim.api.nvim_buf_get_lines()
is a boolean calledstrict_indexing
. It causes the following behaviour:strict_indexing
istrue
out of bounds indices cause an errorstrict_indexing
isfalse
out of bounds indices are clamped to the nearest valid index.So we set strict_indexing to
false
.Now
nvim_buf_get_lines()
returns an array, which might be empty. So attempting to access the first element (our line) could evaluate tonil
.So we use
""
as the fallback line string value.Fixes #349