Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions lua/telescope/_.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,17 @@ function LinesPipe:iter(schedule)
index = nil

local read = self:read()
if previous == nil and read == nil then
return
if read == nil then
if previous == nil then
return nil, true
elseif #previous > 0 then
-- the file doesn't end in a newline. flush the line contents we had and finish.
return previous .. "\n", true
end
end

read = string.gsub(read or "", "\r", "")
return (previous or "") .. read
return (previous or "") .. read, false
end

local next_value = nil
Expand All @@ -181,8 +186,19 @@ function LinesPipe:iter(schedule)
index = string.find(text, "\n", index, true)

if index == nil then
text = get_next_text(string.sub(text, start or 1))
return next_value()
local is_done
text, is_done = get_next_text(string.sub(text, start or 1))
if is_done and text ~= nil then
local res = text
text = nil
index = nil
if schedule then
async.util.scheduler()
end
return res
else
return next_value()
end
end

index = index + 1
Expand Down