implement is_invalid detection
This commit is contained in:
@@ -562,4 +562,15 @@ entry.convert_range_encoding = function(self, range)
|
||||
end)
|
||||
end
|
||||
|
||||
---Return true if the entry is invalid.
|
||||
entry.is_invalid = function(self)
|
||||
local is_invalid = false
|
||||
is_invalid = is_invalid or misc.empty(self.completion_item.label)
|
||||
if self.completion_item.textEdit then
|
||||
local range = self.completion_item.textEdit.range or self.completion_item.textEdit.insert
|
||||
is_invalid = is_invalid or range.start.line ~= range['end'].line
|
||||
end
|
||||
return is_invalid
|
||||
end
|
||||
|
||||
return entry
|
||||
|
||||
@@ -353,13 +353,15 @@ source.complete = function(self, ctx, callback)
|
||||
|
||||
self.status = source.SourceStatus.COMPLETED
|
||||
self.entries = {}
|
||||
for i, item in ipairs(response.items or response) do
|
||||
for _, item in ipairs(response.items or response) do
|
||||
if (item or {}).label then
|
||||
local e = entry.new(ctx, self, item, response.itemDefaults)
|
||||
self.entries[i] = e
|
||||
if not e:is_invalid() then
|
||||
table.insert(self.entries, e)
|
||||
self.offset = math.min(self.offset, e:get_offset())
|
||||
end
|
||||
end
|
||||
end
|
||||
self.revision = self.revision + 1
|
||||
if #self.entries == 0 then
|
||||
self.offset = old_offset
|
||||
|
||||
Reference in New Issue
Block a user