Fix #473
This commit is contained in:
@@ -301,27 +301,31 @@ custom_entries_view._select = function(self, cursor, option)
|
|||||||
self.event:emit('change')
|
self.event:emit('change')
|
||||||
end
|
end
|
||||||
|
|
||||||
custom_entries_view._insert = function(self, word)
|
custom_entries_view._insert = setmetatable({
|
||||||
word = word or ''
|
pending = false,
|
||||||
|
}, {
|
||||||
if api.is_cmdline_mode() then
|
__call = function(this, self, word)
|
||||||
local cursor = api.get_cursor()
|
word = word or ''
|
||||||
local length = vim.str_utfindex(string.sub(api.get_current_line(), self.offset, cursor[2]))
|
if api.is_cmdline_mode() then
|
||||||
vim.api.nvim_feedkeys(keymap.backspace(length) .. word, 'int', true)
|
|
||||||
else
|
|
||||||
local release = require('cmp').core:suspend()
|
|
||||||
feedkeys.call('', 'n', function()
|
|
||||||
local cursor = api.get_cursor()
|
local cursor = api.get_cursor()
|
||||||
local length = vim.str_utfindex(string.sub(api.get_current_line(), self.offset, cursor[2]))
|
local length = vim.str_utfindex(string.sub(api.get_current_line(), self.offset, cursor[2]))
|
||||||
feedkeys.call(
|
vim.api.nvim_feedkeys(keymap.backspace(length) .. word, 'int', true)
|
||||||
keymap.backspace(length) .. word,
|
else
|
||||||
'int',
|
if this.pending then
|
||||||
vim.schedule_wrap(function()
|
return
|
||||||
|
end
|
||||||
|
this.pending = true
|
||||||
|
|
||||||
|
local release = require('cmp').suspend()
|
||||||
|
feedkeys.call('', '', function()
|
||||||
|
local cursor = api.get_cursor()
|
||||||
|
feedkeys.call(keymap.backspace(1 + cursor[2] - self.offset) .. word, 'int', vim.schedule_wrap(function()
|
||||||
|
this.pending = false
|
||||||
release()
|
release()
|
||||||
end)
|
end))
|
||||||
)
|
end)
|
||||||
end)
|
end
|
||||||
end
|
end
|
||||||
end
|
})
|
||||||
|
|
||||||
return custom_entries_view
|
return custom_entries_view
|
||||||
|
|||||||
Reference in New Issue
Block a user