Skip to content

Commit 3c29f19

Browse files
committed
feat(cmd): use cmd table instead of trying to create the cmd string. Fixes #472
1 parent 0dcc907 commit 3c29f19

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

lua/lazy/core/handler/cmd.lua

+15-9
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ end
1414
---@param cmd string
1515
function M:_add(cmd)
1616
vim.api.nvim_create_user_command(cmd, function(event)
17+
local command = {
18+
cmd = cmd,
19+
bang = event.bang or nil,
20+
mods = event.smods,
21+
args = event.fargs,
22+
count = event.count >= 0 and event.count or nil,
23+
}
24+
25+
if event.range == 1 then
26+
command.range = { event.line1 }
27+
elseif event.range == 2 then
28+
command.range = { event.line1, event.line2 }
29+
end
30+
1731
self:_load(cmd)
18-
vim.cmd(
19-
("%s %s%s%s %s"):format(
20-
event.mods or "",
21-
event.line1 == event.line2 and "" or event.line1 .. "," .. event.line2,
22-
cmd,
23-
event.bang and "!" or "",
24-
event.args or ""
25-
)
26-
)
32+
vim.cmd(command)
2733
end, {
2834
bang = true,
2935
range = true,

0 commit comments

Comments
 (0)