Skip to content

Commit 509ca90

Browse files
cryptomilkmfussenegger
authored andcommitted
Fix listing breakpoints if properties are nil instead of empty
E5108: Error executing lua: ~/.local/share/nvim/lazy/nvim-dap/lua/dap/breakpoints.lua:187: invalid value (boolean) at index 2 in table for 'concat' stack traceback: [C]: in function 'concat' ~/.local/share/nvim/lazy/nvim-dap/lua/dap/breakpoints.lua:187: in function 'to_qf_list' ~/.local/share/nvim/lazy/nvim-dap/lua/dap.lua:723: in function 'list_breakpoints' ...azy/telescope-dap.nvim/lua/telescope/_extensions/dap.lua:115: in function 'list_breakpoints' ~/.config/nvim/lua/plugins/dap/init.lua:76: in function <~/.config/nvim/lua/plugins/dap/init.lua:75>
1 parent 76286fd commit 509ca90

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

lua/dap/breakpoints.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ do
180180
local text_parts = {
181181
unpack(api.nvim_buf_get_lines(bufnr, bp.line - 1, bp.line, false), 1),
182182
state.verified == false and (state.message and 'Rejected: ' .. state.message or 'Rejected') or nil,
183-
non_empty(bp.logMessage) and "Log message: " .. bp.logMessage,
184-
non_empty(bp.condition) and "Condition: " .. bp.condition,
185-
non_empty(bp.hitCondition) and "Hit condition: " .. bp.hitCondition,
183+
non_empty(bp.logMessage) and "Log message: " .. bp.logMessage or nil,
184+
non_empty(bp.condition) and "Condition: " .. bp.condition or nil,
185+
non_empty(bp.hitCondition) and "Hit condition: " .. bp.hitCondition or nil,
186186
}
187187
local text = table.concat(vim.tbl_filter(not_nil, text_parts), ', ')
188188
table.insert(qf_list, {

lua/dap/utils.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ function M.to_dict(values, get_key, get_value)
3030
end
3131

3232

33+
---@param object? table|string
34+
---@return boolean
3335
function M.non_empty(object)
3436
if type(object) == "table" then
3537
return next(object) ~= nil
3638
end
37-
return object and #object > 0
39+
return object and #object > 0 or false
3840
end
3941

4042

tests/breakpoints_spec.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,25 @@ describe('breakpoints', function()
7171
},
7272
breakpoints.to_qf_list(breakpoints.get())
7373
)
74+
75+
local bps = {
76+
[buf] = {
77+
{
78+
line = 1,
79+
condition = ""
80+
},
81+
}
82+
}
83+
assert.are.same(
84+
{
85+
{
86+
bufnr = buf,
87+
col = 0,
88+
lnum = 1,
89+
text = "Hello breakpoint"
90+
}
91+
},
92+
breakpoints.to_qf_list(bps)
93+
)
7494
end)
7595
end)

0 commit comments

Comments
 (0)