Skip to content

Commit 17a42c6

Browse files
committed
fix(client): refresh breakpoints on session
See #222
1 parent 3953824 commit 17a42c6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lua/dapui/client/init.lua

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ end
6060
---@field remove fun(bufnr: integer, line: integer)
6161

6262
---@return dapui.BreakpointsProxy
63-
local function create_breakpoints_proxy(breakpoints)
63+
local function create_breakpoints_proxy(breakpoints, session_factory)
6464
local proxy = {}
65+
local function refresh(bufnr)
66+
local bps = breakpoints.get(bufnr)
67+
local session = session_factory()
68+
if session then
69+
session:set_breakpoints(bps)
70+
end
71+
end
72+
6573
proxy.get = function()
6674
return breakpoints.get()
6775
end
@@ -70,9 +78,11 @@ local function create_breakpoints_proxy(breakpoints)
7078
end
7179
proxy.toggle = function(bufnr, line, args)
7280
breakpoints.toggle(args, bufnr, line)
81+
refresh(bufnr)
7382
end
7483
proxy.remove = function(bufnr, line)
7584
breakpoints.remove(bufnr, line)
85+
refresh(bufnr)
7686
end
7787
return proxy
7888
end
@@ -168,7 +178,7 @@ local function create_client(session_factory, breakpoints)
168178
})
169179

170180
local client = setmetatable({
171-
breakpoints = create_breakpoints_proxy(breakpoints),
181+
breakpoints = create_breakpoints_proxy(breakpoints, session_factory),
172182
request = request,
173183
listen = listen,
174184
shutdown = function()

lua/dapui/tests/mocks.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ function M.client(args)
9797
seq = 0,
9898
stopped_thread_id = args.stopped_thread_id,
9999
current_frame = args.current_frame,
100+
set_breakpoints = function() end,
100101

101102
request = function(_, command, request_args, callback)
102103
session.seq = session.seq + 1

0 commit comments

Comments
 (0)