Skip to content

Commit 8d11a2a

Browse files
committed
fix: error when non-current oil buffer has validation errors (#561)
1 parent 09fa1d2 commit 8d11a2a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lua/oil/mutator/init.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,13 @@ M.try_write_changes = function(confirm, cb)
553553
{ all_errors[curbuf][1].lnum + 1, all_errors[curbuf][1].col }
554554
)
555555
else
556-
---@diagnostic disable-next-line: param-type-mismatch
557-
local bufnr, errs = next(pairs(all_errors))
558-
vim.api.nvim_win_set_buf(0, bufnr)
559-
pcall(vim.api.nvim_win_set_cursor, 0, { errs[1].lnum + 1, errs[1].col })
556+
local bufnr, errs = next(all_errors)
557+
-- HACK: This is a workaround for the fact that we can't switch buffers in the middle of a
558+
-- BufWriteCmd.
559+
vim.schedule(function()
560+
vim.api.nvim_win_set_buf(0, bufnr)
561+
pcall(vim.api.nvim_win_set_cursor, 0, { errs[1].lnum + 1, errs[1].col })
562+
end)
560563
end
561564
unlock()
562565
cb("Error parsing oil buffers")

0 commit comments

Comments
 (0)