Skip to content

Commit 3707cdb

Browse files
authored
fix: process all data on_output, even when not terminated with newline (#635)
The current condition prematurely quits processing of data in on_output in some edge-cases. In these cases `job:result()` will have all data, but not everyting was sent through the `on_output` pipes.
1 parent 2d9b061 commit 3707cdb

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lua/plenary/job.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ local on_output = function(self, result_key, cb)
361361
cb(err, result_line, self)
362362
end
363363

364-
if data == nil or is_complete then
364+
if is_complete then
365365
return
366366
end
367367

tests/plenary/job_spec.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe("Job", function()
9999
assert.are.same(job:result(), results)
100100
end)
101101

102-
pending("should split stdin across newlines with no ending newline", function()
102+
it("should split stdin across newlines with no ending newline", function()
103103
local results = {}
104104
local job = Job:new {
105105
-- writer = "hello\nword\nthis is\ntj",
@@ -113,6 +113,8 @@ describe("Job", function()
113113
job:start()
114114
job:send "hello\nwor"
115115
job:send "ld"
116+
117+
wait_for_result(job, { "hello", "world" })
116118
job:shutdown()
117119

118120
assert.are.same(job:result(), { "hello", "world" })
@@ -137,7 +139,7 @@ describe("Job", function()
137139
assert.are.same(job:result(), results)
138140
end)
139141

140-
pending("should return last line when there is no ending newline", function()
142+
it("should return last line when there is no ending newline", function()
141143
local results = {}
142144
local job = Job:new {
143145
command = "printf",

0 commit comments

Comments
 (0)