aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/inlay_hint.lua
diff options
context:
space:
mode:
authorTristan Knight <admin@snappeh.com>2024-09-08 11:44:46 +0100
committerGitHub <noreply@github.com>2024-09-08 03:44:46 -0700
commit003b8a251dc1184e36c222f675bf79a50a40ab3a (patch)
treee30192fa5362163eafc657c6ba5f4d512ee4cb53 /runtime/lua/vim/lsp/inlay_hint.lua
parent0cfbc6eafff731d2d2ecce1f6ceb40be340473f3 (diff)
downloadrneovim-003b8a251dc1184e36c222f675bf79a50a40ab3a.tar.gz
rneovim-003b8a251dc1184e36c222f675bf79a50a40ab3a.tar.bz2
rneovim-003b8a251dc1184e36c222f675bf79a50a40ab3a.zip
fix(lsp): handle out-of-bounds character positions #30288
Problem: str_byteindex_enc could return an error if the index was longer than the lline length. This was handled in each of the calls to it individually Solution: * Fix the call at the source level so that if the index is higher than the line length, line length is returned as per LSP specification * Remove pcalls on str_byteindex_enc calls. No longer needed now that str_byteindex_enc has a bounds check.
Diffstat (limited to 'runtime/lua/vim/lsp/inlay_hint.lua')
-rw-r--r--runtime/lua/vim/lsp/inlay_hint.lua7
1 files changed, 1 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp/inlay_hint.lua b/runtime/lua/vim/lsp/inlay_hint.lua
index 1e224d1bef..4483b083de 100644
--- a/runtime/lua/vim/lsp/inlay_hint.lua
+++ b/runtime/lua/vim/lsp/inlay_hint.lua
@@ -77,12 +77,7 @@ function M.on_inlayhint(err, result, ctx, _)
local col = position.character
if col > 0 then
local line = lines[position.line + 1] or ''
- local ok, convert_result
- ok, convert_result = pcall(util._str_byteindex_enc, line, col, client.offset_encoding)
- if ok then
- return convert_result
- end
- return math.min(#line, col)
+ return util._str_byteindex_enc(line, col, client.offset_encoding)
end
return col
end