mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
perf(validate): use lighter version
- Also fix `vim.validate()` for PUC Lua when showing errors for values that aren't string or number.
This commit is contained in:
committed by
Lewis Russell
parent
fa6ab0d909
commit
3f3e4837d5
@ -473,9 +473,7 @@ do
|
||||
--- @param handle? false|integer
|
||||
--- @return vim.var_accessor
|
||||
local function make_dict_accessor(scope, handle)
|
||||
validate({
|
||||
scope = { scope, 's' },
|
||||
})
|
||||
validate('scope', scope, 'string')
|
||||
local mt = {}
|
||||
function mt:__newindex(k, v)
|
||||
return vim._setvar(scope, handle or 0, k, v)
|
||||
@ -1171,12 +1169,10 @@ function vim.deprecate(name, alternative, version, plugin, backtrace)
|
||||
local displayed = vim._truncated_echo_once(msg)
|
||||
return displayed and msg or nil
|
||||
else
|
||||
vim.validate {
|
||||
name = { name, 'string' },
|
||||
alternative = { alternative, 'string', true },
|
||||
version = { version, 'string', true },
|
||||
plugin = { plugin, 'string', true },
|
||||
}
|
||||
vim.validate('name', name, 'string')
|
||||
vim.validate('alternative', alternative, 'string', true)
|
||||
vim.validate('version', version, 'string', true)
|
||||
vim.validate('plugin', plugin, 'string', true)
|
||||
|
||||
local msg = ('%s is deprecated'):format(name)
|
||||
msg = alternative and ('%s, use %s instead.'):format(msg, alternative) or (msg .. '.')
|
||||
|
Reference in New Issue
Block a user