mirror of
https://github.com/neovim/neovim.git
synced 2026-03-30 04:12:01 +00:00
refactor: integer functions, optimize asserts #34112
refactor(lua): add integer coercion helpers Add vim._tointeger() and vim._ensure_integer(), including optional base support, and switch integer-only tonumber()/assert call sites in the Lua runtime to use them. This also cleans up related integer parsing in LSP, health, loader, URI, tohtml, and Treesitter code. supported by AI
This commit is contained in:
@@ -25,7 +25,7 @@ local PATTERNS = {
|
||||
---@param hex string
|
||||
---@return string
|
||||
local function hex_to_char(hex)
|
||||
return schar(tonumber(hex, 16))
|
||||
return schar(vim._ensure_integer(hex, 16))
|
||||
end
|
||||
|
||||
---@param char string
|
||||
@@ -101,7 +101,7 @@ end
|
||||
---@param uri string
|
||||
---@return string filename or unchanged URI for non-file URIs
|
||||
function M.uri_to_fname(uri)
|
||||
local scheme = assert(uri:match(URI_SCHEME_PATTERN), 'URI must contain a scheme: ' .. uri)
|
||||
local scheme = uri:match(URI_SCHEME_PATTERN) or error('URI must contain a scheme: ' .. uri)
|
||||
if scheme ~= 'file' then
|
||||
return uri
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user