Skip to content

Commit c608ad5

Browse files
committed
fix(linepipe):git_bcommit now can support customized command
1 parent 3466159 commit c608ad5

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lua/telescope/_.lua

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,15 @@ function LinesPipe:iter(schedule)
154154
local text = nil
155155
local index = nil
156156

157-
local get_next_text = function(previous)
157+
local get_next_text = function()
158158
index = nil
159159

160160
local read = self:read()
161-
if previous == nil and read == nil then
161+
if read == nil then
162162
return
163163
end
164164

165-
read = string.gsub(read or "", "\r", "")
166-
return (previous or "") .. read
165+
return string.gsub(read or "", "\r", "")
167166
end
168167

169168
local next_value = nil
@@ -176,17 +175,24 @@ function LinesPipe:iter(schedule)
176175
return nil
177176
end
178177

179-
local start = index
178+
local start = index or 1
180179
index = string.find(text, "\n", index, true)
181180

182181
if index == nil then
183-
text = get_next_text(string.sub(text, start or 1))
184-
return next_value()
182+
local previous = string.sub(text, start)
183+
local next_text = get_next_text()
184+
if next_text then
185+
text = previous .. next_text
186+
return next_value()
187+
else
188+
text = ""
189+
return (#previous > 0) and previous or nil
190+
end
185191
end
186192

187193
index = index + 1
188194

189-
return string.sub(text, start or 1, index - 2)
195+
return string.sub(text, start, index - 2)
190196
end
191197

192198
text = get_next_text()

0 commit comments

Comments
 (0)