Skip to content

Commit 51c2179

Browse files
committed
fix: use vim.F.unpack_len and vim.F.pack_len. Fixes a number of issues...
1 parent 8cd47e0 commit 51c2179

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

lua/noice/source/lsp/progress.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ function M.setup()
8888
})
8989
local orig = vim.lsp.handlers["$/progress"]
9090
vim.lsp.handlers["$/progress"] = function(...)
91-
local args = { ... }
91+
local args = vim.F.pack_len(...)
9292
Util.try(function()
93-
M.progress(unpack(args))
93+
M.progress(vim.F.unpack_len(args))
9494
end)
9595
orig(...)
9696
end

lua/noice/source/lsp/signature.lua

+3-6
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,14 @@ function M.check(buf, chars, encoding)
8787

8888
if vim.tbl_contains(chars, M.get_char(buf)) then
8989
local params = vim.lsp.util.make_position_params(0, encoding)
90-
vim.lsp.buf_request(
91-
buf,
92-
"textDocument/signatureHelp",
93-
params,
94-
vim.lsp.with(require("noice.source.lsp").signature, {
90+
vim.lsp.buf_request(buf, "textDocument/signatureHelp", params, function(err, result, ctx)
91+
require("noice.source.lsp").signature(err, result, ctx, {
9592
trigger = true,
9693
stay = function()
9794
return vim.tbl_contains(chars, M.get_char(buf))
9895
end,
9996
})
100-
)
97+
end)
10198
end
10299
end)
103100
end

lua/noice/util/call.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ function M:notify(err)
128128
end
129129

130130
function M:__call(...)
131-
local args = { ... }
131+
local args = vim.F.pack_len(...)
132132

133133
-- wrap the function and call with args
134134
local wrapped = function()
135-
return self._fn(unpack(args))
135+
return self._fn(vim.F.unpack_len(args))
136136
end
137137

138138
-- error handler
@@ -154,7 +154,7 @@ function M:__call(...)
154154

155155
if not ok and self._defer_retry then
156156
vim.defer_fn(function()
157-
self(unpack(args))
157+
self(vim.F.unpack_len(args))
158158
end, 100)
159159
end
160160

lua/noice/util/hacks.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ M.before_input = false
142142
function M.fix_input()
143143
local function wrap(fn, skip)
144144
return function(...)
145-
local args = { ... }
146-
if skip and skip(unpack(args)) then
147-
return fn(unpack(args))
145+
if skip and skip(...) then
146+
return fn(...)
148147
end
149148

150149
local Manager = require("noice.message.manager")
@@ -155,7 +154,7 @@ function M.fix_input()
155154

156155
M.hide_cursor()
157156
---@type boolean, any
158-
local ok, ret = pcall(fn, unpack(args))
157+
local ok, ret = pcall(fn, ...)
159158
M.show_cursor()
160159

161160
-- clear any message right after input

lua/noice/util/init.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ end
6565
function M.debounce(ms, fn)
6666
local timer = vim.loop.new_timer()
6767
return function(...)
68-
local argv = { ... }
68+
local argv = vim.F.pack_len(...)
6969
timer:start(ms, 0, function()
7070
timer:stop()
71-
vim.schedule_wrap(fn)(unpack(argv))
71+
vim.schedule_wrap(fn)(vim.F.unpack_len(argv))
7272
end)
7373
end
7474
end
@@ -84,11 +84,11 @@ function M.interval(ms, fn, opts)
8484
local timer = vim.loop.new_timer()
8585
local running = false
8686
return function(...)
87-
local args = { ... }
87+
local args = vim.F.pack_len(...)
8888
if not running then
8989
running = true
9090
timer:start(ms, ms, function()
91-
fn(unpack(args))
91+
fn(vim.F.unpack_len(args))
9292
if not (opts.enabled and opts.enabled()) then
9393
timer:stop()
9494
running = false

0 commit comments

Comments
 (0)