Skip to content

Commit

Permalink
chore(registry): clean up recent changes (#1704)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman authored May 11, 2024
1 parent 0f1cb65 commit e91ff44
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions lua/mason-registry/sources/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,21 @@ function FileRegistrySource:install()
---@type ReaddirEntry[]
local entries = _.filter(_.prop_eq("type", "directory"), fs.async.readdir(packages_dir))

local streaming_parser
do
streaming_parser = coroutine.wrap(function()
local buffer = ""
while true do
local delim = buffer:find("\n", 1, true)
if delim then
local content = buffer:sub(1, delim - 1)
buffer = buffer:sub(delim + 1)
local chunk = coroutine.yield(content)
buffer = buffer .. chunk
else
local chunk = coroutine.yield()
buffer = buffer .. chunk
end
local streaming_parser = coroutine.wrap(function()
local buffer = ""
while true do
local delim = buffer:find("\n", 1, true)
if delim then
local content = buffer:sub(1, delim - 1)
buffer = buffer:sub(delim + 1)
local chunk = coroutine.yield(content)
buffer = buffer .. chunk
else
local chunk = coroutine.yield()
buffer = buffer .. chunk
end
end)
end
end
end)

-- Initialize parser coroutine.
streaming_parser()
Expand All @@ -128,7 +125,6 @@ function FileRegistrySource:install()
end
end

a.scheduler()
try(spawn
[yq]({
"-I0", -- output one document per line
Expand Down

0 comments on commit e91ff44

Please sign in to comment.