mirror of
https://github.com/neovim/neovim.git
synced 2026-04-20 06:20:53 +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:
@@ -636,8 +636,7 @@ function M.rename(old_fname, new_fname, opts)
|
||||
local newdir = vim.fs.dirname(new_fname)
|
||||
vim.fn.mkdir(newdir, 'p')
|
||||
|
||||
local ok, err = os.rename(old_fname_full, new_fname)
|
||||
assert(ok, err)
|
||||
assert(os.rename(old_fname_full, new_fname))
|
||||
|
||||
local old_undofile = vim.fn.undofile(old_fname_full)
|
||||
if uv.fs_stat(old_undofile) ~= nil then
|
||||
@@ -1745,10 +1744,10 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
api.nvim_create_autocmd('WinClosed', {
|
||||
group = api.nvim_create_augroup('nvim.closing_floating_preview', { clear = true }),
|
||||
callback = function(args)
|
||||
local winid = tonumber(args.match)
|
||||
local ok, preview_bufnr = pcall(api.nvim_win_get_var, winid, 'lsp_floating_bufnr')
|
||||
local winid = vim._tointeger(args.match)
|
||||
local preview_bufnr = vim.w[winid].lsp_floating_bufnr
|
||||
if
|
||||
ok
|
||||
preview_bufnr
|
||||
and api.nvim_buf_is_valid(preview_bufnr)
|
||||
and winid == vim.b[preview_bufnr].lsp_floating_preview
|
||||
then
|
||||
|
||||
Reference in New Issue
Block a user