commit 40f5115ac43088fb6183a860d5db4ccd206e9bcc
parent 62b45b8fe4cea7010400aa8d6a72062249559186
Author: Yi Ming <ofseed@foxmail.com>
Date: Sun, 24 Aug 2025 20:15:14 +0800
fix(lua): disable `strict_indexing` when converting LSP positions
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/runtime/lua/vim/pos.lua b/runtime/lua/vim/pos.lua
@@ -172,7 +172,9 @@ function Pos.lsp(buf, pos, position_encoding)
-- When on the first character,
-- we can ignore the difference between byte and character.
if col > 0 then
- col = vim.str_byteindex(get_line(buf, row), position_encoding, col)
+ -- `strict_indexing` is disabled, because LSP responses are asynchronous,
+ -- and the buffer content may have changed, causing out-of-bounds errors.
+ col = vim.str_byteindex(get_line(buf, row), position_encoding, col, false)
end
return Pos.new(row, col, { buf = buf })