diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2026-03-12 15:04:05 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-12 11:04:05 -0400 |
| commit | ce1154048b11cdc402d0e5da352a3adca19afb56 (patch) | |
| tree | 02516c918bd7b47e96b02eb83323b917ec4dd37d /runtime/lua/vim/uri.lua | |
| parent | 2fe07cc9658cfca6dcda1b9b37e5f80e38fd7b19 (diff) | |
| download | rneovim-ce1154048b11cdc402d0e5da352a3adca19afb56.tar.gz rneovim-ce1154048b11cdc402d0e5da352a3adca19afb56.tar.bz2 rneovim-ce1154048b11cdc402d0e5da352a3adca19afb56.zip | |
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
Diffstat (limited to 'runtime/lua/vim/uri.lua')
| -rw-r--r-- | runtime/lua/vim/uri.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index 8b6f1a61ee..0e954bcb7a 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -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 |