Skip to content

Commit 6a71e7d

Browse files
committed
fix: fixes error when a utility frame is the current frame
On Mac OS X, small frames that don't allow user focus may be selected when the process filter is processed. By walking up the parent-frame list, we can get to the frame that the user is actually able to use, and thus the call to (get-mru-window) does not return nil and the whole process filter aborts. Should fix bug #828
1 parent 56e92dd commit 6a71e7d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

dap-mode.el

+11-2
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ will be reversed."
784784
(-when-let* ((source (gethash "source" stack-frame))
785785
(sourceReference (gethash "sourceReference" source))
786786
(sourceReferenceKey (format "%s-%s" name sourceReference)))
787-
(select-window (get-mru-window (selected-frame) nil))
787+
(select-window (get-mru-window (dap--selected-frame) nil))
788788
(if-let* ((existing-buffer (get-buffer sourceReferenceKey)))
789789
(switch-to-buffer existing-buffer)
790790
(dap--send-message
@@ -810,6 +810,15 @@ will be reversed."
810810
path)))
811811
(--> debug-session (dap--debug-session-remote-to-local-path-fn it) (funcall it remote-path)))))
812812

813+
(defun dap--selected-frame ()
814+
"Select the 'main' frame when we have a utility/subframe selected"
815+
(cl-labels ((helper (f)
816+
(let ((parent-frame (frame-parameter f 'parent-frame)))
817+
(if parent-frame
818+
(helper parent-frame)
819+
f))))
820+
(helper (selected-frame))))
821+
813822
(defun dap--go-to-stack-frame (debug-session stack-frame)
814823
"Make STACK-FRAME the active STACK-FRAME of DEBUG-SESSION."
815824
(when stack-frame
@@ -821,7 +830,7 @@ will be reversed."
821830
;; stack trace.
822831
(if (and path (file-exists-p path))
823832
(progn
824-
(select-window (get-mru-window (selected-frame) nil))
833+
(select-window (get-mru-window (dap--selected-frame) nil))
825834
(find-file path)
826835
(goto-char (point-min))
827836
(forward-line (1- line))

0 commit comments

Comments
 (0)