Skip to content

Commit

Permalink
fix(client): refresh breakpoints on session
Browse files Browse the repository at this point in the history
See #222
  • Loading branch information
rcarriga committed Jan 31, 2023
1 parent 3953824 commit 17a42c6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lua/dapui/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ end
---@field remove fun(bufnr: integer, line: integer)

---@return dapui.BreakpointsProxy
local function create_breakpoints_proxy(breakpoints)
local function create_breakpoints_proxy(breakpoints, session_factory)
local proxy = {}
local function refresh(bufnr)
local bps = breakpoints.get(bufnr)
local session = session_factory()
if session then
session:set_breakpoints(bps)
end
end

proxy.get = function()
return breakpoints.get()
end
Expand All @@ -70,9 +78,11 @@ local function create_breakpoints_proxy(breakpoints)
end
proxy.toggle = function(bufnr, line, args)
breakpoints.toggle(args, bufnr, line)
refresh(bufnr)
end
proxy.remove = function(bufnr, line)
breakpoints.remove(bufnr, line)
refresh(bufnr)
end
return proxy
end
Expand Down Expand Up @@ -168,7 +178,7 @@ local function create_client(session_factory, breakpoints)
})

local client = setmetatable({
breakpoints = create_breakpoints_proxy(breakpoints),
breakpoints = create_breakpoints_proxy(breakpoints, session_factory),
request = request,
listen = listen,
shutdown = function()
Expand Down
1 change: 1 addition & 0 deletions lua/dapui/tests/mocks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function M.client(args)
seq = 0,
stopped_thread_id = args.stopped_thread_id,
current_frame = args.current_frame,
set_breakpoints = function() end,

request = function(_, command, request_args, callback)
session.seq = session.seq + 1
Expand Down

0 comments on commit 17a42c6

Please sign in to comment.