-
-
Notifications
You must be signed in to change notification settings - Fork 157
fix(inlay_hints): disable strict_indexing for nvim_buf_get_lines #353
base: master
Are you sure you want to change the base?
Conversation
Thanks for this, it fixed the same issue I had 👍 |
Can confirm, this fixes the issue |
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 |
This reverts commit a093f37.
The last parameter of vim.api.nvim_buf_get_lines() is a boolean called "strict_indexing". It causes the following behaviour: - When strict_indexing is "true" out of bounds indices cause an error - When strict_indexing is "false" out of bounds indices are clamped to the nearest valid index. 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.
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