Fix #355
This commit is contained in:
@@ -162,10 +162,9 @@ core.on_change = function(self, event)
|
||||
|
||||
self:autoindent(event, function()
|
||||
local ctx = self:get_context({ reason = types.cmp.ContextReason.Auto })
|
||||
|
||||
debug.log(('ctx: `%s`'):format(ctx.cursor_before_line))
|
||||
if ctx:changed(ctx.prev_context) then
|
||||
self.view:redraw()
|
||||
self.view:on_change()
|
||||
debug.log('changed')
|
||||
|
||||
if vim.tbl_contains(config.get().completion.autocomplete or {}, event) then
|
||||
@@ -262,6 +261,9 @@ core.filter = async.throttle(
|
||||
if not misc.is_suitable_mode() then
|
||||
return
|
||||
end
|
||||
if self.view:get_active_entry() ~= nil then
|
||||
return
|
||||
end
|
||||
local ctx = self:get_context()
|
||||
|
||||
-- To wait for processing source for that's timeout.
|
||||
|
||||
@@ -36,9 +36,9 @@ view.ready = function(self)
|
||||
return self:_get_entries_view():ready()
|
||||
end
|
||||
|
||||
---Redraw menu.
|
||||
view.redraw = function(self)
|
||||
self:_get_entries_view():redraw()
|
||||
---OnChange handler.
|
||||
view.on_change = function(self)
|
||||
self:_get_entries_view():on_change()
|
||||
end
|
||||
|
||||
---Open menu
|
||||
|
||||
@@ -87,8 +87,11 @@ custom_entries_view.ready = function()
|
||||
return vim.fn.pumvisible() == 0
|
||||
end
|
||||
|
||||
custom_entries_view.redraw = function()
|
||||
-- noop
|
||||
custom_entries_view.on_change = function(self)
|
||||
if self:visible() and self:get_active_entry() then
|
||||
self.entries_win:option('cursorline', false)
|
||||
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 1 })
|
||||
end
|
||||
end
|
||||
|
||||
custom_entries_view.open = function(self, offset, entries)
|
||||
@@ -143,7 +146,6 @@ custom_entries_view.open = function(self, offset, entries)
|
||||
end
|
||||
|
||||
local delta = cursor[2] + 1 - self.offset
|
||||
self.entries_win:option('cursorline', false)
|
||||
self.entries_win:open({
|
||||
relative = 'editor',
|
||||
style = 'minimal',
|
||||
@@ -153,6 +155,7 @@ custom_entries_view.open = function(self, offset, entries)
|
||||
height = height,
|
||||
zindex = 1001,
|
||||
})
|
||||
self.entries_win:option('cursorline', false)
|
||||
vim.api.nvim_win_set_cursor(self.entries_win.win, { 1, 1 })
|
||||
|
||||
if preselect > 0 and config.get().preselect == types.cmp.PreselectMode.Item then
|
||||
|
||||
@@ -33,7 +33,7 @@ native_entries_view.ready = function(_)
|
||||
return vim.fn.complete_info({ 'mode' }).mode == 'eval'
|
||||
end
|
||||
|
||||
native_entries_view.redraw = function(self)
|
||||
native_entries_view.on_change = function(self)
|
||||
if #self.entries > 0 and self.offset <= vim.api.nvim_win_get_cursor(0)[2] + 1 then
|
||||
local completeopt = vim.o.completeopt
|
||||
vim.o.completeopt = self.preselect_index == 1 and 'menu,menuone,noinsert' or config.get().completion.completeopt
|
||||
|
||||
Reference in New Issue
Block a user