Skip to content

Commit

Permalink
red: | fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeping committed Sep 13, 2023
1 parent 7f921ca commit 81deebe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions data/lib/red/proc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,20 @@ local function pipe(w, prog, tmp)
local f = io.popen(prog, "r")
if not f then return end
local p = w:run(function()
w:tail()
-- w:tail()
local num = 1
local cur = w:cur()
w:history 'start'
for l in f:lines() do
w:append(l ..'\n')
w.buf:input(l ..'\n')
num = num + 1
if num % 10 == 0 then
if num % 100 == 0 then
coroutine.yield()
end
end
f:close()
w:history 'end'
w:cur(cur)
if tmp then
os.remove(tmp)
end
Expand Down Expand Up @@ -250,7 +254,7 @@ proc['|'] = function(w, prog)

f:write(data.buf:gettext(data.buf:range()))
f:close()
pipe(w:output(), 'cat '..tmp..'|'..prog..' 2>&1', tmp)
pipe(w:data(), 'cat '..tmp..'|'..prog..' 2>&1', tmp)
end
end

Expand Down

0 comments on commit 81deebe

Please sign in to comment.