fix: error when non-current oil buffer has validation errors (#561)

This commit is contained in:
Steven Arcangeli 2025-01-22 08:26:28 -08:00
parent 09fa1d22f5
commit 8d11a2abf3

View file

@ -553,10 +553,13 @@ M.try_write_changes = function(confirm, cb)
{ all_errors[curbuf][1].lnum + 1, all_errors[curbuf][1].col }
)
else
---@diagnostic disable-next-line: param-type-mismatch
local bufnr, errs = next(pairs(all_errors))
vim.api.nvim_win_set_buf(0, bufnr)
pcall(vim.api.nvim_win_set_cursor, 0, { errs[1].lnum + 1, errs[1].col })
local bufnr, errs = next(all_errors)
-- HACK: This is a workaround for the fact that we can't switch buffers in the middle of a
-- BufWriteCmd.
vim.schedule(function()
vim.api.nvim_win_set_buf(0, bufnr)
pcall(vim.api.nvim_win_set_cursor, 0, { errs[1].lnum + 1, errs[1].col })
end)
end
unlock()
cb("Error parsing oil buffers")