Fix #756
This commit is contained in:
@@ -260,20 +260,9 @@ core.complete = function(self, ctx)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Update completion menu
|
---Update completion menu
|
||||||
core.filter = async.throttle(
|
core.filter = async.throttle(function(self)
|
||||||
setmetatable({
|
|
||||||
ctx = nil,
|
|
||||||
}, {
|
|
||||||
__call = function(this, self)
|
|
||||||
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0
|
self.filter.timeout = self.view:visible() and THROTTLE_TIME or 0
|
||||||
|
|
||||||
-- Check context changed.
|
|
||||||
local ctx = self:get_context()
|
|
||||||
if this.ctx and not this.ctx:changed(ctx) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
this.ctx = ctx
|
|
||||||
|
|
||||||
-- Check invalid condition.
|
-- Check invalid condition.
|
||||||
local ignore = false
|
local ignore = false
|
||||||
ignore = ignore or not api.is_suitable_mode()
|
ignore = ignore or not api.is_suitable_mode()
|
||||||
@@ -293,6 +282,8 @@ core.filter = async.throttle(
|
|||||||
table.insert(sources, s)
|
table.insert(sources, s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local ctx = self:get_context()
|
||||||
|
|
||||||
-- Display completion results.
|
-- Display completion results.
|
||||||
self.view:open(ctx, sources)
|
self.view:open(ctx, sources)
|
||||||
|
|
||||||
@@ -307,10 +298,7 @@ core.filter = async.throttle(
|
|||||||
end) == 0 then
|
end) == 0 then
|
||||||
config.set_onetime({})
|
config.set_onetime({})
|
||||||
end
|
end
|
||||||
end
|
end, THROTTLE_TIME)
|
||||||
}),
|
|
||||||
THROTTLE_TIME
|
|
||||||
)
|
|
||||||
|
|
||||||
---Confirm completion.
|
---Confirm completion.
|
||||||
---@param e cmp.Entry
|
---@param e cmp.Entry
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ describe('keymap', function()
|
|||||||
|
|
||||||
describe('realworld', function()
|
describe('realworld', function()
|
||||||
before_each(spec.before)
|
before_each(spec.before)
|
||||||
|
|
||||||
it('#226', function()
|
it('#226', function()
|
||||||
keymap.listen('i', '<c-n>', function(_, fallback)
|
keymap.listen('i', '<c-n>', function(_, fallback)
|
||||||
fallback()
|
fallback()
|
||||||
@@ -101,6 +102,7 @@ describe('keymap', function()
|
|||||||
vim.api.nvim_feedkeys(keymap.t('iaiueo<CR>a<C-n><C-n>'), 'tx', true)
|
vim.api.nvim_feedkeys(keymap.t('iaiueo<CR>a<C-n><C-n>'), 'tx', true)
|
||||||
assert.are.same({ 'aiueo', 'aiueo' }, vim.api.nvim_buf_get_lines(0, 0, -1, true))
|
assert.are.same({ 'aiueo', 'aiueo' }, vim.api.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('#414', function()
|
it('#414', function()
|
||||||
keymap.listen('i', '<M-j>', function()
|
keymap.listen('i', '<M-j>', function()
|
||||||
vim.api.nvim_feedkeys(keymap.t('<C-n>'), 'int', true)
|
vim.api.nvim_feedkeys(keymap.t('<C-n>'), 'int', true)
|
||||||
@@ -108,5 +110,17 @@ describe('keymap', function()
|
|||||||
vim.api.nvim_feedkeys(keymap.t('iaiueo<CR>a<M-j><M-j>'), 'tx', true)
|
vim.api.nvim_feedkeys(keymap.t('iaiueo<CR>a<M-j><M-j>'), 'tx', true)
|
||||||
assert.are.same({ 'aiueo', 'aiueo' }, vim.api.nvim_buf_get_lines(0, 0, -1, true))
|
assert.are.same({ 'aiueo', 'aiueo' }, vim.api.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- it('#744', function()
|
||||||
|
-- vim.api.nvim_buf_set_keymap(0, 'i', '<C-r>', 'recursive', {
|
||||||
|
-- noremap = true
|
||||||
|
-- })
|
||||||
|
-- vim.api.nvim_buf_set_keymap(0, 'i', '<CR>', '<CR>recursive', {
|
||||||
|
-- noremap = false
|
||||||
|
-- })
|
||||||
|
-- keymap.listen('i', '<CR>', function(_, fallback) fallback() end)
|
||||||
|
-- feedkeys.call(keymap.t('i<CR>'), 'tx')
|
||||||
|
-- assert.are.same({ '', 'recursive' }, vim.api.nvim_buf_get_lines(0, 0, -1, true))
|
||||||
|
-- end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -197,8 +197,7 @@ view._get_entries_view = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---On entry change
|
---On entry change
|
||||||
view.on_entry_change = async.throttle(
|
view.on_entry_change = async.throttle(function(self)
|
||||||
function(self)
|
|
||||||
if not self:visible() then
|
if not self:visible() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -225,8 +224,6 @@ view.on_entry_change = async.throttle(
|
|||||||
else
|
else
|
||||||
self.ghost_text_view:hide()
|
self.ghost_text_view:hide()
|
||||||
end
|
end
|
||||||
end,
|
end, 20)
|
||||||
20
|
|
||||||
)
|
|
||||||
|
|
||||||
return view
|
return view
|
||||||
|
|||||||
Reference in New Issue
Block a user