Skip to content

Commit 40f5115

Browse files
committed
fix(lua): disable strict_indexing when converting LSP positions
1 parent 62b45b8 commit 40f5115

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

runtime/lua/vim/pos.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ function Pos.lsp(buf, pos, position_encoding)
172172
-- When on the first character,
173173
-- we can ignore the difference between byte and character.
174174
if col > 0 then
175-
col = vim.str_byteindex(get_line(buf, row), position_encoding, col)
175+
-- `strict_indexing` is disabled, because LSP responses are asynchronous,
176+
-- and the buffer content may have changed, causing out-of-bounds errors.
177+
col = vim.str_byteindex(get_line(buf, row), position_encoding, col, false)
176178
end
177179

178180
return Pos.new(row, col, { buf = buf })

0 commit comments

Comments
 (0)