Fix cmdline confirmation bug
This commit is contained in:
@@ -297,7 +297,7 @@ core.filter = async.throttle(
|
|||||||
---@param callback function
|
---@param callback function
|
||||||
core.confirm = function(self, e, option, callback)
|
core.confirm = function(self, e, option, callback)
|
||||||
if not (e and not e.confirmed) then
|
if not (e and not e.confirmed) then
|
||||||
return
|
return callback()
|
||||||
end
|
end
|
||||||
e.confirmed = true
|
e.confirmed = true
|
||||||
|
|
||||||
@@ -319,9 +319,17 @@ core.confirm = function(self, e, option, callback)
|
|||||||
|
|
||||||
-- Restore the state again without modify the `.` register.
|
-- Restore the state again without modify the `.` register.
|
||||||
end, function(next)
|
end, function(next)
|
||||||
vim.api.nvim_set_current_line(e.context.cursor_line)
|
if api.is_cmdline_mode() then
|
||||||
vim.api.nvim_win_set_cursor(0, { e.context.cursor.row, e.context.cursor.col - 1 })
|
local ctx = context.new()
|
||||||
next()
|
local keys = {}
|
||||||
|
table.insert(keys, keymap.backspace(ctx.cursor.character - vim.str_utfindex(ctx.cursor_line, e:get_offset() - 1)))
|
||||||
|
table.insert(keys, string.sub(e.context.cursor_before_line, e:get_offset()))
|
||||||
|
feedkeys.call(table.concat(keys, ''), 'nt', next)
|
||||||
|
else
|
||||||
|
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()
|
||||||
|
end
|
||||||
|
|
||||||
-- Async additionalTextEdits @see https://github.com/microsoft/vscode/blob/main/src/vs/editor/contrib/suggest/suggestController.ts#L334
|
-- Async additionalTextEdits @see https://github.com/microsoft/vscode/blob/main/src/vs/editor/contrib/suggest/suggestController.ts#L334
|
||||||
end, function(next)
|
end, function(next)
|
||||||
|
|||||||
Reference in New Issue
Block a user