Fix #262
This commit is contained in:
@@ -226,12 +226,23 @@ end
|
||||
---@param callback function
|
||||
core.autoindent = function(event, callback)
|
||||
if event == types.cmp.TriggerEvent.TextChanged then
|
||||
local ctx = context.new()
|
||||
local prefix = pattern.matchstr('[^[:blank:]]\\+$', ctx.cursor_before_line)
|
||||
local cursor_before_line = misc.get_cursor_before_line()
|
||||
local prefix = pattern.matchstr('[^[:blank:]]\\+$', cursor_before_line)
|
||||
if prefix then
|
||||
for _, key in ipairs(vim.split(vim.bo.indentkeys, ',')) do
|
||||
if vim.tbl_contains({ '=' .. prefix, '0=' .. prefix }, key) then
|
||||
return keymap.feedkeys(keymap.t('<Plug>(cmp-autoindent)'), '', callback)
|
||||
return vim.schedule(function()
|
||||
if cursor_before_line == misc.get_cursor_before_line() then
|
||||
local indentkeys = vim.bo.indentkeys
|
||||
vim.bo.indentkeys = indentkeys .. ',!^F'
|
||||
keymap.feedkeys(keymap.t('<C-f>'), 'n', function()
|
||||
vim.bo.indentkeys = indentkeys
|
||||
callback()
|
||||
end)
|
||||
else
|
||||
callback()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user