mirror of
https://github.com/hrsh7th/cmp-buffer
synced 2025-05-05 09:46:30 +00:00
Merge 5b0a943e32
into b74fab3656
This commit is contained in:
commit
252feeee1a
@ -312,8 +312,10 @@ function buffer.index_line(self, linenr, line)
|
||||
-- In other words, if the line contains more characters than the max limit,
|
||||
-- then it will always contain more bytes than the same limit.
|
||||
-- This check is here because calling a Vimscript function is relatively slow.
|
||||
local sliced = false
|
||||
if #remaining > self.opts.max_indexed_line_length then
|
||||
remaining = vim.fn.strcharpart(line, 0, self.opts.max_indexed_line_length)
|
||||
sliced = true
|
||||
end
|
||||
while #remaining > 0 do
|
||||
-- NOTE: Both start and end indexes here are 0-based (unlike Lua strings),
|
||||
@ -330,6 +332,13 @@ function buffer.index_line(self, linenr, line)
|
||||
break
|
||||
end
|
||||
end
|
||||
-- The last indexed word may not be an actual word if the line is sliced at
|
||||
-- the middle of a word. Remove it to avoid polluting the index. Note that
|
||||
-- this may remove an actual word, but this is ok since we've already
|
||||
-- compromised completeness of the index of long lines.
|
||||
if sliced and word_i > 1 then
|
||||
words[word_i - 1] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function buffer.get_words(self)
|
||||
|
Loading…
Reference in New Issue
Block a user