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

fix: fixes error when a utility frame is the current frame #837

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions dap-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ will be reversed."
(-when-let* ((source (gethash "source" stack-frame))
(sourceReference (gethash "sourceReference" source))
(sourceReferenceKey (format "%s-%s" name sourceReference)))
(select-window (get-mru-window (selected-frame) nil))
(select-window (get-mru-window (dap--selected-frame) nil))
(if-let* ((existing-buffer (get-buffer sourceReferenceKey)))
(switch-to-buffer existing-buffer)
(dap--send-message
Expand All @@ -810,6 +810,15 @@ will be reversed."
path)))
(--> debug-session (dap--debug-session-remote-to-local-path-fn it) (funcall it remote-path)))))

(defun dap--selected-frame ()
"Select the 'main' frame when we have a utility/subframe selected"
(cl-labels ((helper (f)
(let ((parent-frame (frame-parameter f 'parent-frame)))
(if parent-frame
(helper parent-frame)
f))))
(helper (selected-frame))))

(defun dap--go-to-stack-frame (debug-session stack-frame)
"Make STACK-FRAME the active STACK-FRAME of DEBUG-SESSION."
(when stack-frame
Expand All @@ -821,7 +830,7 @@ will be reversed."
;; stack trace.
(if (and path (file-exists-p path))
(progn
(select-window (get-mru-window (selected-frame) nil))
(select-window (get-mru-window (dap--selected-frame) nil))
(find-file path)
(goto-char (point-min))
(forward-line (1- line))
Expand Down