mirror of
https://github.com/hrsh7th/nvim-cmp
synced 2024-09-16 20:54:03 +02:00
Improve recently_used
This commit is contained in:
parent
9c00c34b6b
commit
ffba3d8388
3 changed files with 19 additions and 3 deletions
|
@ -37,6 +37,9 @@ core.new = function()
|
|||
self.view.event:on('keymap', function(...)
|
||||
self:on_keymap(...)
|
||||
end)
|
||||
self.view.event:on('closed', function(e)
|
||||
self.event:emit('closed', e)
|
||||
end)
|
||||
return self
|
||||
end
|
||||
|
||||
|
@ -447,7 +450,9 @@ core.confirm = function(self, e, option, callback)
|
|||
feedkeys.call('', 'n', function()
|
||||
e:execute(vim.schedule_wrap(function()
|
||||
release()
|
||||
self.event:emit('confirm_done', e)
|
||||
self.event:emit('confirm_done', {
|
||||
entry = e
|
||||
})
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
|
|
|
@ -308,8 +308,16 @@ autocmd.subscribe('CursorMoved', function()
|
|||
end
|
||||
end)
|
||||
|
||||
cmp.event:on('closed', function(e)
|
||||
if e.entry then
|
||||
cmp.config.compare.recently_used:add_entry(e.entry)
|
||||
end
|
||||
end)
|
||||
|
||||
cmp.event:on('confirm_done', function(e)
|
||||
cmp.config.compare.recently_used:add_entry(e)
|
||||
if e.entry then
|
||||
cmp.config.compare.recently_used:add_entry(e.entry)
|
||||
end
|
||||
end)
|
||||
|
||||
return cmp
|
||||
|
|
|
@ -109,8 +109,11 @@ view.open = function(self, ctx, sources)
|
|||
end
|
||||
end
|
||||
|
||||
-- close.
|
||||
-- closed.
|
||||
if #entries == 0 then
|
||||
self.event:emit('closed', {
|
||||
entry = self:_get_entries_view():get_selected_entry()
|
||||
})
|
||||
self:close()
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue