mirror of
https://github.com/neovim/neovim.git
synced 2026-07-11 03:49:41 +00:00
fix(api): nvim_cmd() "args" type too narrow #40670
Problem: nvim_cmd() accepts number/boolean in args and converts them to strings, but the keyset declares ArrayOf(String). Solution: use ArrayOf(Union(Integer, String, Boolean)) and wrap union types in parens when generating array annotations.
This commit is contained in:
2
runtime/lua/vim/_meta/api_keysets.gen.lua
generated
2
runtime/lua/vim/_meta/api_keysets.gen.lua
generated
@@ -26,7 +26,7 @@ error('Cannot require a meta file')
|
||||
|
||||
--- @class vim.api.keyset.cmd
|
||||
--- @field addr? "line"|"arg"|"buf"|"load"|"win"|"tab"|"qf"|"none"|"?"
|
||||
--- @field args? string[]
|
||||
--- @field args? (integer|string|boolean)[]
|
||||
--- @field bang? boolean
|
||||
--- @field cmd? string
|
||||
--- @field count? integer
|
||||
|
||||
@@ -37,6 +37,10 @@ local function api_type(t)
|
||||
if count then
|
||||
return ('[%s]'):format(ty:rep(count, ', '))
|
||||
else
|
||||
-- "foo|bar" => "(foo|bar)"
|
||||
if ty:find('|', 1, true) and not vim.startswith(ty, '[') then
|
||||
ty = ('(%s)'):format(ty)
|
||||
end
|
||||
return ty .. '[]'
|
||||
end
|
||||
elseif container == 'Dict' or container == 'DictAs' then
|
||||
|
||||
@@ -314,7 +314,7 @@ typedef struct {
|
||||
Integer count;
|
||||
String reg;
|
||||
Boolean bang;
|
||||
ArrayOf(String) args;
|
||||
ArrayOf(Union(Integer, String, Boolean)) args;
|
||||
DictAs(cmd__magic) magic;
|
||||
DictAs(cmd__mods) mods;
|
||||
Union(Integer, Enum("?", "+", "*")) nargs;
|
||||
|
||||
Reference in New Issue
Block a user