Skip to content

Commit

Permalink
fix(dap): format sourceMap correctly for both codelldb and lldb
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Nov 27, 2023
1 parent 878dc7a commit a0eaffc
Show file tree
Hide file tree
Showing 2 changed files with 19 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).

## [Unreleased]

### Fixed

- DAP: Format `sourceMap` correctly for both `codelldb` and `lldb`.
`codelldb` expects a map, while `lldb` expects a list of tuples.

## [3.6.5] - 2023-11-22

### Fixed
Expand Down
13 changes: 12 additions & 1 deletion lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ local function tbl_to_tuple_list(tbl)
return result
end

---codelldb expects a map,
-- while lldb expects a list of tuples.
---@param tbl { [string]: string }
---@return string[][] | { [string]: string }
local function format_source_map(tbl)
if adapter.type == 'server' then
return tbl
end
return tbl_to_tuple_list(tbl)
end

---@type DapSourceMap
local source_map = {}

Expand Down Expand Up @@ -204,7 +215,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 = tbl_to_tuple_list(source_map) })
and vim.tbl_deep_extend('force', dap_config, { sourceMap = format_source_map(source_map) })
or dap_config
-- start debugging
dap.run(final_config)
Expand Down

0 comments on commit a0eaffc

Please sign in to comment.