Skip to content

Commit cba670d

Browse files
committed
fix: dap-firefox
Shamelessly stolen from: emacs-lsp#755
1 parent c19147a commit cba670d

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

dap-firefox.el

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,44 @@
4444

4545
(defun dap-firefox--populate-start-file-args (conf)
4646
"Populate CONF with the required arguments."
47-
(-> conf
48-
(dap--put-if-absent :dap-server-path dap-firefox-debug-program)
49-
(dap--put-if-absent :type "Firefox")
50-
(dap--put-if-absent :cwd default-directory)
51-
(dap--put-if-absent :file (expand-file-name (read-file-name "Select the file to open in the browser:" nil (buffer-file-name) t)))
52-
(dap--put-if-absent :name "Firefox Debug")))
47+
(setq conf (-> conf
48+
(plist-put :type "firefox")
49+
(plist-put :dap-server-path dap-firefox-debug-program)
50+
(dap--put-if-absent :cwd (expand-file-name default-directory))))
51+
(dap--plist-delete
52+
(pcase (plist-get conf :mode)
53+
("url" (-> conf
54+
(dap--put-if-absent :url (read-string
55+
"Browse url: "
56+
"http://localhost:5371" t))
57+
(dap--put-if-absent :webRoot (lsp-workspace-root))))
58+
("file" (dap--put-if-absent conf :file
59+
(read-file-name "Select the file to open in the browser:" nil (buffer-file-name) t)))
60+
(_ conf))
61+
:mode))
5362

5463
(dap-register-debug-provider "firefox" 'dap-firefox--populate-start-file-args)
5564

56-
(dap-register-debug-template "Firefox Run Configuration"
65+
(dap-register-debug-template "Firefox Browse File"
5766
(list :type "firefox"
67+
:mode "file"
5868
:cwd nil
5969
:request "launch"
6070
:file nil
71+
:reattach t
72+
:program nil
73+
:name "Firefox Browse File"))
74+
75+
(dap-register-debug-template "Firefox Browse URL"
76+
(list :type "firefox"
77+
:mode "url"
78+
:cwd nil
79+
:request "launch"
80+
:webRoot nil
81+
:url nil
6182
:reAttach t
6283
:program nil
63-
:name "Firefox::Run"))
84+
:name "Firefox Browse URL"))
6485

6586
(provide 'dap-firefox)
6687
;;; dap-firefox.el ends here

0 commit comments

Comments
 (0)