Skip to content

Commit

Permalink
fix: do not add executable to adapter when remote mode is used
Browse files Browse the repository at this point in the history
This prevents the executable from being added to the adapter when remote
mode is used. This allows the plugin to attach to already running
instances that are run through `dlv exec` to perform remote debugging.
  • Loading branch information
jsternberg committed Aug 22, 2024
1 parent 5511788 commit 52eec69
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lua/dap-go.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ local default_config = {
port = "${port}",
args = {},
build_flags = "",
-- Automativally handle the issue on Windows where delve needs
-- to be run in attched mode or it will fail (actually crashes).
-- Automatically handle the issue on Windows where delve needs
-- to be run in attached mode or it will fail (actually crashes).
detached = vim.fn.has("win32") == 0,
},
tests = {
Expand Down Expand Up @@ -91,6 +91,12 @@ local function setup_delve_adapter(dap, config)
host = "127.0.0.1"
end

-- Remove the executable if used in remote mode.
-- This will prevent the executable from being launched.
if client_config.mode == "remote" then
delve_config.executable = nil
end

local listener_addr = host .. ":" .. client_config.port
delve_config.port = client_config.port
delve_config.executable.args = { "dap", "-l", listener_addr }
Expand Down

0 comments on commit 52eec69

Please sign in to comment.