Skip to content

Commit

Permalink
fix(lsp): use new vim.str_byteindex if available to calculate start p…
Browse files Browse the repository at this point in the history
…ositions of LSP ranges
  • Loading branch information
folke committed Nov 26, 2024
1 parent 3dc00c0 commit 86746d2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/trouble/sources/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ local Util = require("trouble.util")
---@param encoding string utf-8|utf-16|utf-32| defaults to utf-16
---@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)
end
local ok, ret = pcall(vim.lsp.util._str_byteindex_enc, line, index, encoding)
return ok and ret or #line
end
Expand Down

0 comments on commit 86746d2

Please sign in to comment.