Skip to content

Commit 15e980d

Browse files
committed
fix: dap-firefox
Shamelessly stolen from: emacs-lsp#755
1 parent 302fb05 commit 15e980d

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

dap-firefox.el

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,46 @@
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 (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+
52+
(dap--plist-delete
53+
(pcase (plist-get conf :mode)
54+
("url" (-> conf
55+
(dap--put-if-absent :url (read-string
56+
"Browse url: "
57+
"http://localhost:5371" t))
58+
(dap--put-if-absent :webRoot (lsp-workspace-root))))
59+
60+
("file" (dap--put-if-absent conf :file
61+
(read-file-name "Select the file to open in the browser:" nil (buffer-file-name) t)))
62+
(_ conf))
63+
:mode))
5364

5465
(dap-register-debug-provider "firefox" 'dap-firefox--populate-start-file-args)
5566

56-
(dap-register-debug-template "Firefox Run Configuration"
67+
(dap-register-debug-template "Firefox Browse File"
5768
(list :type "firefox"
69+
:mode "file"
5870
:cwd nil
5971
:request "launch"
6072
:file nil
6173
:reAttach t
74+
:program nil
75+
:name "Firefox Browse File"))
76+
77+
(dap-register-debug-template "Firefox Browse URL"
78+
(list :type "firefox"
79+
:mode "url"
80+
:cwd nil
81+
:request "launch"
82+
:webRoot nil
83+
:url nil
84+
:reAttach t
6285
:program nil
63-
:name "Firefox::Run"))
86+
:name "Firefox Browse URL"))
6487

6588
(provide 'dap-firefox)
6689
;;; dap-firefox.el ends here

0 commit comments

Comments
 (0)