From 81e900fe55b6b56860fafd04f399241de7f5f033 Mon Sep 17 00:00:00 2001 From: Lukas Reineke Date: Thu, 31 Aug 2023 17:13:42 +0900 Subject: [PATCH] stop the rg job when max items is reached fix #49 --- lua/cmp-rg/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/cmp-rg/init.lua b/lua/cmp-rg/init.lua index c2979d9..99d03c8 100644 --- a/lua/cmp-rg/init.lua +++ b/lua/cmp-rg/init.lua @@ -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 }