Skip to content

Commit

Permalink
fix(lsp): use old-style args for vim.str_byteindex. Fixes #604
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Nov 26, 2024
1 parent b4b9355 commit c633e85
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/trouble/sources/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ local Util = require("trouble.util")
---@return integer byte (utf-8) index of `encoding` index `index` in `line`
local function get_line_col(line, index, encoding)
if vim.str_byteindex then
return vim.str_byteindex(line, encoding, index)
-- FIXME: uses old-style func signature, since there's no way to
-- properly detect if new style is available
return vim.str_byteindex(line, index, encoding == "utf-16")
end
local ok, ret = pcall(vim.lsp.util._str_byteindex_enc, line, index, encoding)
return ok and ret or #line
Expand Down

0 comments on commit c633e85

Please sign in to comment.