Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Fix startup issue in dap.lua #433

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions lua/rust-tools/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,25 @@ function M.start(args)

-- only process artifact if it's valid json object and it is a compiler artifact
if
type(artifact) ~= "table"
or artifact.reason ~= "compiler-artifact"
type(artifact) == "table"
and artifact.reason == "compiler-artifact"
then
goto loop_end
local is_binary =
rt.utils.contains(artifact.target.crate_types, "bin")
local is_build_script =
rt.utils.contains(artifact.target.kind, "custom-build")
local is_test = (
(artifact.profile.test == true) and (artifact.executable ~= nil)
) or rt.utils.contains(artifact.target.kind, "test")
-- only add executable to the list if we want a binary debug and it is a binary
-- or if we want a test debug and it is a test
if
(cargo_args[1] == "build" and is_binary and not is_build_script)
or (cargo_args[1] == "test" and is_test)
then
table.insert(executables, artifact.executable)
end
end

local is_binary =
rt.utils.contains(artifact.target.crate_types, "bin")
local is_build_script =
rt.utils.contains(artifact.target.kind, "custom-build")
local is_test = (
(artifact.profile.test == true) and (artifact.executable ~= nil)
) or rt.utils.contains(artifact.target.kind, "test")
-- only add executable to the list if we want a binary debug and it is a binary
-- or if we want a test debug and it is a test
if
(cargo_args[1] == "build" and is_binary and not is_build_script)
or (cargo_args[1] == "test" and is_test)
then
table.insert(executables, artifact.executable)
end

::loop_end::
end

-- only 1 executable is allowed for debugging - error out if zero or many were found
Expand Down