Skip to content

Commit 7319607

Browse files
committed
Use local session variable in run_to_cursor
The global variable may change between the initial call and a callback. A local variable ensures the whole operation uses the same session.
1 parent 75a94b8 commit 7319607

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lua/dap.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,11 +799,12 @@ end
799799

800800

801801
function M.run_to_cursor()
802-
if not session then
802+
local lsession = session
803+
if not lsession then
803804
notify('Cannot use run_to_cursor without active session', vim.log.levels.INFO)
804805
return
805806
end
806-
if not session.stopped_thread_id then
807+
if not lsession.stopped_thread_id then
807808
notify('run_to_cursor can only be used if stopped at a breakpoint', vim.log.levels.INFO)
808809
return
809810
end
@@ -840,13 +841,13 @@ function M.run_to_cursor()
840841
lazy.breakpoints.set(opts, buf, line)
841842
end
842843
end
843-
session:set_breakpoints(bps_before, nil)
844+
lsession:set_breakpoints(bps_before, nil)
844845
end
845846

846847
M.listeners.before.event_stopped['dap.run_to_cursor'] = restore_breakpoints
847848
M.listeners.before.event_terminated['dap.run_to_cursor'] = restore_breakpoints
848-
session:set_breakpoints(temp_bps, function()
849-
session:_step('continue')
849+
lsession:set_breakpoints(temp_bps, function()
850+
lsession:_step('continue')
850851
end)
851852
end
852853

0 commit comments

Comments
 (0)