Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dap): only add sourceMap and lldb commands if the files exist #102

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ 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]
## [3.10.2] - 2023-12-18

### Fixed

- DAP: Only add sourceMap and lldb commands if the files exist.
- DAP (Windows): Fixed .exe extension in mason.nvim codelldb detection.
Thanks [@svermeulen](https://github.com/svermeulen)!

Expand Down
2 changes: 1 addition & 1 deletion lua/rustaceanvim/commands/crate_graph.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ local function handler_factory(backend, output, pipe)
end

graph = string.gsub(graph, '\n', '')
print('rust-tools: Processing crate graph. This may take a while...')
vim.notify('rustaceanvim: Processing crate graph. This may take a while...')

local cmd = 'dot -T' .. backend
if pipe ~= nil then -- optionally pipe to `pipe`
Expand Down
21 changes: 17 additions & 4 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,20 @@ local source_maps = {}
local function generate_source_map(workspace_root)
get_rustc_commit_hash(function(commit_hash)
get_rustc_sysroot(function(rustc_sysroot)
local src_path
for _, src_dir in pairs { 'src', 'rustc-src' } do
src_path = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', src_dir, 'rust')
if compat.uv.fs_stat(src_path) then
break
end
src_path = nil
end
if not src_path then
return
end
---@type DapSourceMap
local new_map = {
[compat.joinpath('/rustc', commit_hash)] = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'src', 'rust'),
[compat.joinpath('/rustc', commit_hash)] = src_path,
}
source_maps[workspace_root] = vim.tbl_extend('force', source_maps[workspace_root] or {}, new_map)
end)
Expand All @@ -126,9 +137,11 @@ local init_commands = {}

local function get_lldb_commands(workspace_root)
get_rustc_sysroot(function(rustc_sysroot)
local script_import = 'command script import "'
.. compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'etc', 'lldb_lookup.py')
.. '"'
local script = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'etc', 'lldb_lookup.py')
if not compat.uv.fs_stat(script) then
return
end
local script_import = 'command script import "' .. script .. '"'
local commands_file = compat.joinpath(rustc_sysroot, 'lib', 'rustlib', 'etc', 'lldb_commands')
local file = io.open(commands_file, 'r')
local workspace_root_cmds = {}
Expand Down