|
108 | 108 | local source_maps = {} |
109 | 109 |
|
110 | 110 | ---See https://github.com/vadimcn/codelldb/issues/204 |
111 | | ----@param workspace_root string |
| 111 | +---@param workspace_root? string |
112 | 112 | local function generate_source_map(workspace_root) |
113 | | - if source_maps[workspace_root] then |
| 113 | + if not workspace_root or source_maps[workspace_root] then |
114 | 114 | return |
115 | 115 | end |
116 | 116 | get_rustc_commit_hash(function(commit_hash) |
|
137 | 137 | ---@type {[string]: string[]} |
138 | 138 | local init_commands = {} |
139 | 139 |
|
| 140 | +---@param workspace_root? string |
140 | 141 | local function get_lldb_commands(workspace_root) |
141 | | - if init_commands[workspace_root] then |
| 142 | + if not workspace_root or init_commands[workspace_root] then |
142 | 143 | return |
143 | 144 | end |
144 | 145 | get_rustc_sysroot(function(rustc_sysroot) |
@@ -182,9 +183,9 @@ local environments = {} |
182 | 183 |
|
183 | 184 | -- Most succinct description: https://github.com/bevyengine/bevy/issues/2589#issuecomment-1753413600 |
184 | 185 | ---@param adapter DapExecutableConfig | DapServerConfig |
185 | | ----@param workspace_root string |
| 186 | +---@param workspace_root string | nil |
186 | 187 | local function add_dynamic_library_paths(adapter, workspace_root) |
187 | | - if environments[workspace_root] then |
| 188 | + if not workspace_root or environments[workspace_root] then |
188 | 189 | return |
189 | 190 | end |
190 | 191 | compat.system({ 'rustc', '--print', 'target-libdir' }, nil, function(sc) |
@@ -345,19 +346,21 @@ function M.start(args, verbose, callback) |
345 | 346 | final_config.cwd = args.workspaceRoot |
346 | 347 | final_config.program = executables[1] |
347 | 348 | final_config.args = args.executableArgs or {} |
348 | | - local environment = environments[args.workspaceRoot] |
| 349 | + local environment = args.workspaceRoot and environments[args.workspaceRoot] |
349 | 350 | final_config = next(environment or {}) ~= nil |
350 | 351 | and vim.tbl_deep_extend('force', final_config, { env = environment }) |
351 | 352 | or final_config |
352 | 353 |
|
353 | 354 | if string.find(final_config.type, 'lldb') ~= nil then |
354 | 355 | -- lldb specific entries |
355 | | - final_config = next(init_commands or {}) ~= nil |
| 356 | + final_config = args.workspaceRoot |
| 357 | + and next(init_commands or {}) ~= nil |
356 | 358 | and vim.tbl_deep_extend('force', final_config, { initCommands = init_commands[args.workspaceRoot] }) |
357 | 359 | or final_config |
358 | 360 |
|
359 | | - local source_map = source_maps[args.workspaceRoot] |
360 | | - final_config = next(source_map or {}) ~= nil |
| 361 | + local source_map = args.workspaceRoot and source_maps[args.workspaceRoot] |
| 362 | + final_config = source_map |
| 363 | + and next(source_map or {}) ~= nil |
361 | 364 | and vim.tbl_deep_extend('force', final_config, { sourceMap = format_source_map(adapter, source_map) }) |
362 | 365 | or final_config |
363 | 366 | elseif string.find(final_config.type, 'probe%-rs') ~= nil then |
|
0 commit comments