mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
feat: tostring(vim.version())
Problem: tostring(vim.version()) returns "table: 0x…". Solution: Modify vim.version() to return a string prerelease instead of a boolean. Fix #23863
This commit is contained in:
@@ -425,7 +425,7 @@ setmetatable(M, {
|
|||||||
__call = function()
|
__call = function()
|
||||||
local version = vim.fn.api_info().version
|
local version = vim.fn.api_info().version
|
||||||
-- Workaround: vim.fn.api_info().version reports "prerelease" as a boolean.
|
-- Workaround: vim.fn.api_info().version reports "prerelease" as a boolean.
|
||||||
version.prerelease = version.prerelease or nil
|
version.prerelease = version.prerelease and 'dev' or nil
|
||||||
return setmetatable(version, Version)
|
return setmetatable(version, Version)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@@ -17,6 +17,18 @@ describe('version', function()
|
|||||||
eq({ major = 42, minor = 3, patch = 99 }, exec_lua("return vim.version.parse('v42.3.99')"))
|
eq({ major = 42, minor = 3, patch = 99 }, exec_lua("return vim.version.parse('v42.3.99')"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('version() returns Nvim version', function()
|
||||||
|
local expected = exec_lua('return vim.fn.api_info().version')
|
||||||
|
local actual = exec_lua('return vim.version()')
|
||||||
|
eq(expected.major, actual.major)
|
||||||
|
eq(expected.minor, actual.minor)
|
||||||
|
eq(expected.patch, actual.patch)
|
||||||
|
eq(expected.prerelease and 'dev' or nil, actual.prerelease)
|
||||||
|
|
||||||
|
-- tostring() #23863
|
||||||
|
matches([[%d+%.%d+%.%d+]], exec_lua('return tostring(vim.version())'))
|
||||||
|
end)
|
||||||
|
|
||||||
describe('_version()', function()
|
describe('_version()', function()
|
||||||
local tests = {
|
local tests = {
|
||||||
['v1.2.3'] = { major = 1, minor = 2, patch = 3 },
|
['v1.2.3'] = { major = 1, minor = 2, patch = 3 },
|
||||||
|
Reference in New Issue
Block a user