Fix #1142
This commit is contained in:
@@ -125,7 +125,7 @@ custom_entries_view.open = function(self, offset, entries)
|
|||||||
local entries_buf = self.entries_win:get_buffer()
|
local entries_buf = self.entries_win:get_buffer()
|
||||||
local lines = {}
|
local lines = {}
|
||||||
local dedup = {}
|
local dedup = {}
|
||||||
local preselect = 0
|
local preselect_index = 0
|
||||||
for _, e in ipairs(entries) do
|
for _, e in ipairs(entries) do
|
||||||
local view = e:get_view(offset, entries_buf)
|
local view = e:get_view(offset, entries_buf)
|
||||||
if view.dup == 1 or not dedup[e.completion_item.label] then
|
if view.dup == 1 or not dedup[e.completion_item.label] then
|
||||||
@@ -135,8 +135,8 @@ custom_entries_view.open = function(self, offset, entries)
|
|||||||
self.column_width.menu = math.max(self.column_width.menu, view.menu.width)
|
self.column_width.menu = math.max(self.column_width.menu, view.menu.width)
|
||||||
table.insert(self.entries, e)
|
table.insert(self.entries, e)
|
||||||
table.insert(lines, ' ')
|
table.insert(lines, ' ')
|
||||||
if preselect == 0 and e.completion_item.preselect then
|
if preselect_index == 0 and e.completion_item.preselect then
|
||||||
preselect = #self.entries
|
preselect_index = #self.entries
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -187,8 +187,8 @@ custom_entries_view.open = function(self, offset, entries)
|
|||||||
for i = 1, math.floor(n / 2) do
|
for i = 1, math.floor(n / 2) do
|
||||||
self.entries[i], self.entries[n - i + 1] = self.entries[n - i + 1], self.entries[i]
|
self.entries[i], self.entries[n - i + 1] = self.entries[n - i + 1], self.entries[i]
|
||||||
end
|
end
|
||||||
if preselect ~= 0 then
|
if preselect_index ~= 0 then
|
||||||
preselect = #self.entries - preselect + 1
|
preselect_index = #self.entries - preselect_index + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -207,8 +207,8 @@ custom_entries_view.open = function(self, offset, entries)
|
|||||||
})
|
})
|
||||||
-- always set cursor when starting. It will be adjusted on the call to _select
|
-- always set cursor when starting. It will be adjusted on the call to _select
|
||||||
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 0 })
|
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 0 })
|
||||||
if preselect > 0 and config.get().preselect == types.cmp.PreselectMode.Item then
|
if preselect_index > 0 and config.get().preselect == types.cmp.PreselectMode.Item then
|
||||||
self:_select(preselect, { behavior = types.cmp.SelectBehavior.Select })
|
self:_select(preselect_index, { behavior = types.cmp.SelectBehavior.Select })
|
||||||
elseif not string.match(config.get().completion.completeopt, 'noselect') then
|
elseif not string.match(config.get().completion.completeopt, 'noselect') then
|
||||||
if self:is_direction_top_down() then
|
if self:is_direction_top_down() then
|
||||||
self:_select(1, { behavior = types.cmp.SelectBehavior.Select })
|
self:_select(1, { behavior = types.cmp.SelectBehavior.Select })
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ native_entries_view.open = function(self, offset, entries)
|
|||||||
end
|
end
|
||||||
|
|
||||||
native_entries_view.close = function(self)
|
native_entries_view.close = function(self)
|
||||||
if api.is_suitable_mode() and self:visible() then
|
if api.is_insert_mode() and self:visible() then
|
||||||
vim.fn.complete(1, {})
|
|
||||||
vim.api.nvim_select_popupmenu_item(-1, false, true, {})
|
vim.api.nvim_select_popupmenu_item(-1, false, true, {})
|
||||||
end
|
end
|
||||||
self.offset = -1
|
self.offset = -1
|
||||||
|
|||||||
Reference in New Issue
Block a user