Skip to content

Commit 8eb1af0

Browse files
committed
revert vim.split
1 parent 3521c2f commit 8eb1af0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lua/crates/semver.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ function M.compare_pre(version, req)
223223
return -1
224224
end
225225

226+
---@param str string
227+
---@return string[]
228+
local function split_identifiers(str)
229+
local parts = {}
230+
for part in str:gmatch("[^%.]+") do
231+
table.insert(parts, part)
232+
end
233+
return parts
234+
end
235+
226236
---@param str string
227237
---@return boolean
228238
local function is_numeric(str)
@@ -248,8 +258,8 @@ function M.compare_pre(version, req)
248258
end
249259
end
250260

251-
local version_parts = version and vim.split(version, ".") or {}
252-
local req_parts = req and vim.split(req, ".") or {}
261+
local version_parts = version and split_identifiers(version) or {}
262+
local req_parts = req and split_identifiers(req) or {}
253263

254264
local max_len = math.max(#version_parts, #req_parts)
255265

0 commit comments

Comments
 (0)