1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

Add error handling for resuming the cursor

This will close issue #328.
This commit is contained in:
jdhao 2024-08-29 21:40:06 +02:00
parent 12b0ff02b6
commit 4b4ff5f549

View File

@ -163,7 +163,11 @@ api.nvim_create_autocmd("FileType", {
-- vim.print(string.format("mark_pos: %s", vim.inspect(mark_pos)))
-- it seems that without vim.schedule, the cursor position can not be set correctly
vim.schedule(function()
api.nvim_win_set_cursor(0, mark_pos)
local status, result = pcall(api.nvim_win_set_cursor, 0, mark_pos)
if not status then
api.nvim_err_writeln(string.format("Failed to resume cursor position. Context %s, error: %s",
vim.inspect(ev), result))
end
end)
end
end,