Skip to content

Commit

Permalink
fix(dap): prevent parallel cargo test builds (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Sep 12, 2024
1 parent 1997658 commit 5610d5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion lua/rustaceanvim/commands/debuggables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,28 @@ 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
configuration.name = name
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[]
Expand Down

0 comments on commit 5610d5e

Please sign in to comment.