Fix incorrect highlight
This commit is contained in:
@@ -82,7 +82,7 @@ source.get_entries = function(self, ctx)
|
||||
return {}
|
||||
end
|
||||
|
||||
local prev_entries = (function()
|
||||
local target_entries = (function()
|
||||
local key = { 'get_entries', self.revision }
|
||||
for i = ctx.cursor.col, self.offset, -1 do
|
||||
key[3] = string.sub(ctx.cursor_before_line, 1, i)
|
||||
@@ -91,36 +91,27 @@ source.get_entries = function(self, ctx)
|
||||
return prev_entries
|
||||
end
|
||||
end
|
||||
return nil
|
||||
return self.entries
|
||||
end)()
|
||||
|
||||
local entries = self.cache:ensure({ 'get_entries', self.revision, ctx.cursor_before_line }, function()
|
||||
debug.log(self:get_debug_name(), 'filter', #(prev_entries or self.entries))
|
||||
|
||||
local inputs = {}
|
||||
local entries = {}
|
||||
for _, e in ipairs(prev_entries or self.entries) do
|
||||
local o = e:get_offset()
|
||||
if not inputs[o] then
|
||||
inputs[o] = string.sub(ctx.cursor_before_line, o)
|
||||
end
|
||||
local score, matches = matcher.match(inputs[o], e:get_filter_text(), { e:get_word() })
|
||||
e.score = score
|
||||
e.exact = false
|
||||
if e.score >= 1 then
|
||||
if e:get_filter_text() ~= e.completion_item.label then
|
||||
local _, matches_for_highlights = matcher.match(inputs[o], e.completion_item.label, {})
|
||||
e.matches = matches_for_highlights
|
||||
else
|
||||
e.matches = matches
|
||||
end
|
||||
e.exact = e:get_filter_text() == inputs[o] or e:get_word() == inputs[o]
|
||||
table.insert(entries, e)
|
||||
end
|
||||
local inputs = {}
|
||||
local entries = {}
|
||||
for _, e in ipairs(target_entries) do
|
||||
local o = e:get_offset()
|
||||
if not inputs[o] then
|
||||
inputs[o] = string.sub(ctx.cursor_before_line, o)
|
||||
end
|
||||
|
||||
return entries
|
||||
end)
|
||||
local match = e:match(inputs[o])
|
||||
e.score = match.score
|
||||
e.exact = false
|
||||
if e.score >= 1 then
|
||||
e.matches = match.matches
|
||||
e.exact = e:get_filter_text() == inputs[o] or e:get_word() == inputs[o]
|
||||
table.insert(entries, e)
|
||||
end
|
||||
end
|
||||
self.cache:set({ 'get_entries', self.revision, ctx.cursor_before_line }, entries)
|
||||
|
||||
local max_item_count = self:get_config().max_item_count or 200
|
||||
local limited_entries = {}
|
||||
|
||||
Reference in New Issue
Block a user