mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
fix(version): return nil with empty string
This commit is contained in:
parent
60967cd9aa
commit
8bdfc2ab2b
@ -174,6 +174,10 @@ function M._version(version, strict) -- Adapted from https://github.com/folke/la
|
|||||||
version = version:match('%d[^ ]*')
|
version = version:match('%d[^ ]*')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if version == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
local prerel = version:match('%-([^+]*)')
|
local prerel = version:match('%-([^+]*)')
|
||||||
local prerel_strict = version:match('%-([0-9A-Za-z-]*)')
|
local prerel_strict = version:match('%-([0-9A-Za-z-]*)')
|
||||||
if
|
if
|
||||||
|
@ -112,6 +112,10 @@ describe('version', function()
|
|||||||
assert(vim.version.range('1.2.3-alpha'):has('1.2.3-alpha'))
|
assert(vim.version.range('1.2.3-alpha'):has('1.2.3-alpha'))
|
||||||
assert(not vim.version.range('1.2.3-alpha'):has('1.2.3-beta'))
|
assert(not vim.version.range('1.2.3-alpha'):has('1.2.3-beta'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('returns nil with empty version', function()
|
||||||
|
eq(vim.version.parse(''), nil)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('cmp()', function()
|
describe('cmp()', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user