Skip to content

Commit 764cc62

Browse files
committed
fix supporting unicode in signature
1 parent 91524a8 commit 764cc62

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

script/proto/converter.lua

+8
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ function m.setOffsetEncoding(encoding)
207207
offsetEncoding = encoding:lower():gsub('%-', '')
208208
end
209209

210+
---@param s string
211+
---@param i? integer
212+
---@param j? integer
213+
---@return integer
214+
function m.len(s, i, j)
215+
return encoder.len(offsetEncoding, s, i, j)
216+
end
217+
210218
---@class proto.command
211219
---@field title string
212220
---@field command string

script/provider/provider.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,8 @@ m.register 'textDocument/signatureHelp' {
772772
for j, param in ipairs(result.params) do
773773
parameters[j] = {
774774
label = {
775-
param.label[1],
776-
param.label[2],
775+
converter.len(result.label, 1, param.label[1]),
776+
converter.len(result.label, 1, param.label[2]),
777777
}
778778
}
779779
end

test/signature/init.lua

+14
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,17 @@ t(<??>)
330330
{
331331
'function (<!x: number!>)',
332332
}
333+
334+
TEST [[
335+
---@class 😅
336+
337+
---@param a 😅
338+
---@param b integer
339+
local function f(a, b)
340+
end
341+
342+
f(1, 2<??>)
343+
]]
344+
{
345+
'function f(a: 😅, <!b: integer!>)',
346+
}

0 commit comments

Comments
 (0)