This commit is contained in:
hrsh7th
2021-11-10 04:28:32 +09:00
parent faaf1c9629
commit 6071062289
2 changed files with 11 additions and 12 deletions

View File

@@ -308,21 +308,20 @@ core.confirm = function(self, e, option, callback)
-- Close menus.
self.view:close()
-- Simulate `<C-y>` behavior.
-- Simulate <C-y> behavior and store the `.` register.
async.step(function(next)
local ctx = context.new()
local confirm = {}
table.insert(confirm, keymap.backspace(ctx.cursor.character - misc.to_utfindex(e.context.cursor_before_line, e:get_offset())))
table.insert(confirm, e:get_word())
table.insert(confirm, keymap.undobreak())
feedkeys.call(table.concat(confirm, ''), 'nt', next)
local keys = {}
table.insert(keys, keymap.backspace(ctx.cursor.character - vim.str_utfindex(ctx.cursor_line, e:get_offset() - 1)))
table.insert(keys, e:get_word())
table.insert(keys, keymap.undobreak())
feedkeys.call(table.concat(keys, ''), 'nt', next)
-- Restore to the requested state.
-- Restore the state again without modify the `.` register.
end, function(next)
local restore = {}
table.insert(restore, keymap.backspace(vim.str_utfindex(e:get_word())))
table.insert(restore, string.sub(e.context.cursor_before_line, e:get_offset()))
feedkeys.call(table.concat(restore, ''), 'n', next)
vim.api.nvim_set_current_line(e.context.cursor_line)
vim.api.nvim_win_set_cursor(0, { e.context.cursor.row, e.context.cursor.col - 1 })
next()
-- Async additionalTextEdits @see https://github.com/microsoft/vscode/blob/main/src/vs/editor/contrib/suggest/suggestController.ts#L334
end, function(next)

View File

@@ -69,7 +69,7 @@ keymap.backspace = function(count)
return ''
end
local keys = {}
table.insert(keys, keymap.t(string.rep(keymap.undojoin() .. '<Left><Del>', count)))
table.insert(keys, keymap.t(string.rep('<BS>', count)))
return table.concat(keys, '')
end