File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 105105--- @return lsp.Location
106106local function item_to_location (item , offset_encoding )
107107 local line = item .lnum - 1
108- local character = vim . lsp . util . _str_utfindex_enc (item .text , item .col , offset_encoding ) - 1
108+ local character = utils . str_byteindex (item .text , item .col , offset_encoding or " utf-16 " ) - 1
109109 local uri
110110 if utils .is_uri (item .filename ) then
111111 uri = item .filename
Original file line number Diff line number Diff line change @@ -17,6 +17,18 @@ local utils = {}
1717
1818utils .iswin = vim .loop .os_uname ().sysname == " Windows_NT"
1919
20+ --- @param s string
21+ --- @param i number
22+ --- @param encoding " utf-8" | " utf-16" | " utf-32"
23+ --- @return integer
24+ utils .str_byteindex = function (s , i , encoding )
25+ if vim .fn .has " nvim-0.11" == 1 then
26+ return vim .str_byteindex (s , encoding , i , false )
27+ else
28+ return vim .lsp .util ._str_byteindex_enc (s , i , encoding )
29+ end
30+ end
31+
2032-- TODO(clason): Remove when dropping support for Nvim 0.9
2133utils .islist = vim .fn .has " nvim-0.10" == 1 and vim .islist or vim .tbl_islist
2234local flatten = function (t )
You can’t perform that action at this time.
0 commit comments