From 5610d5e01dc803717cc0b6b87625f2fbb548b49e Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Thu, 12 Sep 2024 23:36:07 +0700 Subject: [PATCH] fix(dap): prevent parallel cargo test builds (#501) --- CHANGELOG.md | 8 ++++++++ lua/rustaceanvim/commands/debuggables.lua | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4115fc26..64c94158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [5.4.2] - 2024-09-12 + +### Fixed + +- When adding DAP configurations + (`vim.g.rustaceanvim.dap.autoload_configurations = true`, default), + wait for compilation before spawning another process for the next compilation. + ## [5.4.1] - 2024-09-10 ### Fixed diff --git a/lua/rustaceanvim/commands/debuggables.lua b/lua/rustaceanvim/commands/debuggables.lua index 28be6099..acb7b893 100644 --- a/lua/rustaceanvim/commands/debuggables.lua +++ b/lua/rustaceanvim/commands/debuggables.lua @@ -120,7 +120,17 @@ local function add_debuggables_to_nvim_dap(debuggables) end local rt_dap = require('rustaceanvim.dap') dap.configurations.rust = dap.configurations.rust or {} - for _, debuggable in pairs(debuggables) do + -- To prevent parallel 'cargo build" processes, we + -- iterate over the debuggables using a recursive function. + -- We can't use vim.system():wait(), because it blocks the UI. + local iter = vim.iter(debuggables) + ---@type function + local go + go = function() + local debuggable = iter:next() + if not debuggable then + return + end rt_dap.start(debuggable.args, false, function(configuration) local name = 'Cargo: ' .. build_label(debuggable.args) if not _dap_configuration_added[name] then @@ -128,8 +138,10 @@ local function add_debuggables_to_nvim_dap(debuggables) table.insert(dap.configurations.rust, configuration) _dap_configuration_added[name] = true end + go() end) end + pcall(go) -- Ignore stack overflow errors end ---@param debuggables rustaceanvim.RARunnable[]