Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore stopped state if goto errors #1334

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions lua/dap/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,18 @@ function Session:_request_scopes(current_frame)
end


---@param session dap.Session
local function clear_running(session, thread_id)
vim.fn.sign_unplace(session.sign_group)
thread_id = thread_id or session.stopped_thread_id
session.stopped_thread_id = nil
local thread = session.threads[thread_id]
if thread then
thread.stopped = false
end
end


--- Goto specified line (source and col are optional)
function Session:_goto(line, source, col)
local frame = self.current_frame
Expand Down Expand Up @@ -845,14 +857,16 @@ function Session:_goto(line, source, col)
if not target then
return
end
local params = {threadId = self.stopped_thread_id, targetId = target.id }
local thread = self.threads[self.stopped_thread_id]
if thread then
thread.stopped = false
end
self.stopped_thread_id = nil
local stopped_thread_id = self.stopped_thread_id
local params = {threadId = stopped_thread_id, targetId = target.id }
local thread = self.threads[stopped_thread_id]
clear_running(self, stopped_thread_id)
local goto_err = self:request('goto', params)
if goto_err then
self.stopped_thread_id = stopped_thread_id
if thread then
thread.stopped = true
end
utils.notify('Error executing goto: ' .. utils.fmt_error(goto_err), vim.log.levels.ERROR)
end
end)()
Expand Down Expand Up @@ -1550,18 +1564,6 @@ function Session:_pause(thread_id, cb)
end


---@param session dap.Session
local function clear_running(session, thread_id)
vim.fn.sign_unplace(session.sign_group)
thread_id = thread_id or session.stopped_thread_id
session.stopped_thread_id = nil
local thread = session.threads[thread_id]
if thread then
thread.stopped = false
end
end


function Session:restart_frame()
if not self.capabilities.supportsRestartFrame then
utils.notify('Debug Adapter does not support restart frame', vim.log.levels.INFO)
Expand Down
Loading