implement is_invalid detection
This commit is contained in:
@@ -562,4 +562,15 @@ entry.convert_range_encoding = function(self, range)
|
|||||||
end)
|
end)
|
||||||
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
|
return entry
|
||||||
|
|||||||
@@ -353,11 +353,13 @@ source.complete = function(self, ctx, callback)
|
|||||||
|
|
||||||
self.status = source.SourceStatus.COMPLETED
|
self.status = source.SourceStatus.COMPLETED
|
||||||
self.entries = {}
|
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
|
if (item or {}).label then
|
||||||
local e = entry.new(ctx, self, item, response.itemDefaults)
|
local e = entry.new(ctx, self, item, response.itemDefaults)
|
||||||
self.entries[i] = e
|
if not e:is_invalid() then
|
||||||
self.offset = math.min(self.offset, e:get_offset())
|
table.insert(self.entries, e)
|
||||||
|
self.offset = math.min(self.offset, e:get_offset())
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.revision = self.revision + 1
|
self.revision = self.revision + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user