Skip to content

Commit

Permalink
fix(linepipe):git_bcommit now can support customized command
Browse files Browse the repository at this point in the history
  • Loading branch information
Marskey committed Jan 4, 2024
1 parent 3466159 commit ab0e7ee
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lua/telescope/_.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,15 @@ function LinesPipe:iter(schedule)
local text = nil
local index = nil

local get_next_text = function(previous)
local get_next_text = function()
index = nil

local read = self:read()
if previous == nil and read == nil then
if read == nil then
return
end

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

local next_value = nil
Expand All @@ -176,17 +175,24 @@ function LinesPipe:iter(schedule)
return nil
end

local start = index
local start = index or 1
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 previous = string.sub(text, start)
local next_text = get_next_text()
if next_text then
text = previous .. next_text
return next_value()
else
text = ""
return previous
end
end

index = index + 1

return string.sub(text, start or 1, index - 2)
return string.sub(text, start, index - 2)
end

text = get_next_text()
Expand Down

0 comments on commit ab0e7ee

Please sign in to comment.