rust-tools.nvim
rust-tools.nvim copied to clipboard
fix(inlay_hints): disable strict_indexing for nvim_buf_get_lines
The last parameter of vim.api.nvim_buf_get_lines() is a boolean called strict_indexing. It causes the following behaviour:
- When
strict_indexingistrueout of bounds indices cause an error - When
strict_indexingisfalseout 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 to nil.
So we use "" as the fallback line string value.
Fixes #349
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.