Skip to content

Commit

Permalink
fix(dap): make sourceMap a list of tuples, not a map (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Nov 19, 2023
1 parent e45fdde commit 540ff82
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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).

## [3.6.4] - 2023-11-19

### Fixed

## [3.6.3] - 2023-11-18

- DAP: Source map should be a list of tuples, not a map.

### Fixed

- DAP: `lldb-vscode` and `lldb-dap` executable detection.
Expand Down
21 changes: 17 additions & 4 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ local function get_rustc_commit_hash(callback)
if sc.code ~= 0 or result == nil then
return
end
local commit_hash = result:match('commit%-hash:%s+([^\n]+)$')
local commit_hash = result:match('commit%-hash:%s+([^\n]+)')
if not commit_hash then
return
end
Expand All @@ -91,6 +91,19 @@ end

---@alias DapSourceMap {[string]: string}

---@param tbl { [string]: string }
---@return string[][]
local function tbl_to_tuple_list(tbl)
---@type string[][]
local result = {}
for k, v in pairs(tbl) do
---@type string[]
local tuple = { k, v }
table.insert(result, tuple)
end
return result
end

---@type DapSourceMap
local source_map = {}

Expand All @@ -100,9 +113,9 @@ local function generate_source_map()
get_rustc_sysroot(function(rustc_sysroot)
---@type DapSourceMap
local new_map = {
[compat.joinpath('/rustc/', commit_hash)] = compat.joinpath(rustc_sysroot, '/lib/rustlib/src/rust'),
[compat.joinpath('/rustc', commit_hash)] = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'src', 'rust'),
}
vim.tbl_extend('force', source_map, { new_map })
source_map = vim.tbl_extend('force', source_map, new_map)
end)
end)
end
Expand Down Expand Up @@ -191,7 +204,7 @@ function M.start(args)
}
local final_config = is_generate_source_map_enabled
and next(source_map) ~= nil
and vim.tbl_deep_extend('force', dap_config, { sourceMap = source_map })
and vim.tbl_deep_extend('force', dap_config, { sourceMap = tbl_to_tuple_list(source_map) })
or dap_config
-- start debugging
dap.run(final_config)
Expand Down

0 comments on commit 540ff82

Please sign in to comment.