From 0b21d02f243ddf63bb84ee4ee33f42d8ae0c457b Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 27 Jan 2026 16:42:16 -0500 Subject: [PATCH] fix(runner): save buffer before compile --- lua/cp/runner/execute.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/cp/runner/execute.lua b/lua/cp/runner/execute.lua index a60ffa3..5c89c8a 100644 --- a/lua/cp/runner/execute.lua +++ b/lua/cp/runner/execute.lua @@ -177,6 +177,16 @@ function M.compile_problem(debug, on_complete) local language = state.get_language() or config.platforms[platform].default_language local eff = config.runtime.effective[platform][language] + local source_file = state.get_source_file() + if source_file then + local buf = vim.fn.bufnr(source_file) + if buf ~= -1 and vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].modified then + vim.api.nvim_buf_call(buf, function() + vim.cmd.write({ mods = { silent = true, noautocmd = true } }) + end) + end + end + local compile_config = (debug and eff.commands.debug) or eff.commands.build if not compile_config then