mirror of
https://github.com/hrsh7th/cmp-buffer
synced 2025-05-06 10:09:52 +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,
|
-- In other words, if the line contains more characters than the max limit,
|
||||||
-- then it will always contain more bytes than the same limit.
|
-- then it will always contain more bytes than the same limit.
|
||||||
-- This check is here because calling a Vimscript function is relatively slow.
|
-- This check is here because calling a Vimscript function is relatively slow.
|
||||||
|
local sliced = false
|
||||||
if #remaining > self.opts.max_indexed_line_length then
|
if #remaining > self.opts.max_indexed_line_length then
|
||||||
remaining = vim.fn.strcharpart(line, 0, self.opts.max_indexed_line_length)
|
remaining = vim.fn.strcharpart(line, 0, self.opts.max_indexed_line_length)
|
||||||
|
sliced = true
|
||||||
end
|
end
|
||||||
while #remaining > 0 do
|
while #remaining > 0 do
|
||||||
-- NOTE: Both start and end indexes here are 0-based (unlike Lua strings),
|
-- 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
|
break
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
function buffer.get_words(self)
|
function buffer.get_words(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user