Skip to content

Commit

Permalink
fix(neotest): undo sanitize command for debugging in normal strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Apr 14, 2024
1 parent 553a319 commit 78cbea3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ 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).

## [4.22.2] - 2024-04-14

### Fixed

- Neotest/DAP: Undo sanitize command for debugging when running with
a non-dap strategy, in case it was sanitized during a dap strategy run.

## [4.22.1] - 2024-04-14

### Fixed
Expand Down
4 changes: 3 additions & 1 deletion lua/rustaceanvim/neotest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local lib = require('neotest.lib')
local nio = require('nio')
local trans = require('rustaceanvim.neotest.trans')
local cargo = require('rustaceanvim.cargo')
local overrides = require('rustaceanvim.overrides')

---@package
---@type neotest.Adapter
Expand Down Expand Up @@ -239,7 +240,6 @@ function NeotestAdapter.build_spec(run_args)
local exe, args, cwd = require('rustaceanvim.runnables').get_command(runnable)
if run_args.strategy == 'dap' then
local dap = require('rustaceanvim.dap')
local overrides = require('rustaceanvim.overrides')
overrides.sanitize_command_for_debugging(runnable.args.cargoArgs)
local future = nio.control.future()
dap.start(runnable.args, false, function(strategy)
Expand All @@ -260,6 +260,8 @@ function NeotestAdapter.build_spec(run_args)
strategy = strategy,
}
return run_spec
else
overrides.undo_debug_sanitize(runnable.args.cargoArgs)
end
---@type rustaceanvim.neotest.RunSpec
---@diagnostic disable-next-line: missing-fields
Expand Down
10 changes: 10 additions & 0 deletions lua/rustaceanvim/overrides.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,14 @@ function M.sanitize_command_for_debugging(command)
end
end

---Undo sanitize_command_for_debugging.
---@param command string[]
function M.undo_debug_sanitize(command)
if command[1] == 'build' then
command[1] = 'run'
elseif command[1] == 'test' and command[2] == '--no-run' then
table.remove(command, 2)
end
end

return M

0 comments on commit 78cbea3

Please sign in to comment.