Skip to content

Commit

Permalink
Merge pull request #50 from lukas-reineke/stop-job-when-max-items-rea…
Browse files Browse the repository at this point in the history
…ched

stop the rg job when max items is reached
  • Loading branch information
lukas-reineke authored Sep 1, 2023
2 parents 1cad8eb + 81e900f commit dde00ad
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lua/cmp-rg/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ source.complete = function(self, request, callback)
end
end
end

if request.max_item_count ~= nil and #items >= request.max_item_count then
vim.fn.jobstop(self.running_job_id)
callback { items = items, isIncomplete = false }
return
end

if #items - chunk_size >= chunk_size then
chunk_size = chunk_size * 2
callback { items = items, isIncomplete = true }
Expand Down

0 comments on commit dde00ad

Please sign in to comment.