rename indexing_chunk_size to indexing_batch_size

This commit is contained in:
Dmytro Meleshko 2021-12-20 12:37:28 +02:00
parent a3ab9bec60
commit c8daddb987
2 changed files with 10 additions and 9 deletions

View File

@ -150,16 +150,16 @@ function buffer.start_indexing_timer(self)
self.timer_current_line = self.timer_current_line + 1 self.timer_current_line = self.timer_current_line + 1
end end
local chunk_start = self.timer_current_line local batch_start = self.timer_current_line
local chunk_size = self.opts.indexing_chunk_size local batch_size = self.opts.indexing_batch_size
-- NOTE: self.lines_count may be modified by the indexer. -- NOTE: self.lines_count may be modified by the indexer.
local chunk_end = chunk_size >= 1 and math.min(chunk_start + chunk_size, self.lines_count) or self.lines_count local batch_end = batch_size >= 1 and math.min(batch_start + batch_size, self.lines_count) or self.lines_count
if chunk_end >= self.lines_count then if batch_end >= self.lines_count then
self:stop_indexing_timer() self:stop_indexing_timer()
end end
self:index_range(chunk_start, chunk_end, true) self:index_range(batch_start, batch_end, true)
self.timer_current_line = chunk_end self.timer_current_line = batch_end
self:mark_all_lines_dirty() self:mark_all_lines_dirty()
end) end)
end end

View File

@ -4,7 +4,7 @@ local buffer = require('cmp_buffer.buffer')
---@field public keyword_length number ---@field public keyword_length number
---@field public keyword_pattern string ---@field public keyword_pattern string
---@field public get_bufnrs fun(): number[] ---@field public get_bufnrs fun(): number[]
---@field public indexing_chunk_size number ---@field public indexing_batch_size number
---@field public indexing_interval number ---@field public indexing_interval number
---@type cmp_buffer.Options ---@type cmp_buffer.Options
@ -14,7 +14,7 @@ local defaults = {
get_bufnrs = function() get_bufnrs = function()
return { vim.api.nvim_get_current_buf() } return { vim.api.nvim_get_current_buf() }
end, end,
indexing_chunk_size = 1000, indexing_batch_size = 1000,
indexing_interval = 100, indexing_interval = 100,
} }
@ -33,7 +33,7 @@ source._validate_options = function(_, params)
keyword_length = { opts.keyword_length, 'number' }, keyword_length = { opts.keyword_length, 'number' },
keyword_pattern = { opts.keyword_pattern, 'string' }, keyword_pattern = { opts.keyword_pattern, 'string' },
get_bufnrs = { opts.get_bufnrs, 'function' }, get_bufnrs = { opts.get_bufnrs, 'function' },
indexing_chunk_size = { opts.indexing_chunk_size, 'number' }, indexing_batch_size = { opts.indexing_batch_size, 'number' },
indexing_interval = { opts.indexing_interval, 'number' }, indexing_interval = { opts.indexing_interval, 'number' },
}) })
return opts return opts
@ -82,6 +82,7 @@ source.complete = function(self, params, callback)
end end
---@param opts cmp_buffer.Options ---@param opts cmp_buffer.Options
---@return cmp_buffer.Buffer[]
source._get_buffers = function(self, opts) source._get_buffers = function(self, opts)
local buffers = {} local buffers = {}
for _, bufnr in ipairs(opts.get_bufnrs()) do for _, bufnr in ipairs(opts.get_bufnrs()) do