From a4c3974f69663eca84d249245325471d249fc8da Mon Sep 17 00:00:00 2001 From: Nikita Bloshchanevich Date: Thu, 26 Nov 2020 15:07:45 +0100 Subject: [PATCH 1/2] `dap-start-debugging-noexpand': expand :cwd In a previous commit, :cwd was expanded specifically in `dap-chrome'. Undo that, and centralize expanding :cwd in `dap-start-debugging-noexpand'. This allows :cwd to be a relative path. Fixes #413. --- dap-chrome.el | 2 +- dap-mode.el | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dap-chrome.el b/dap-chrome.el index a3f1643f..5636696e 100644 --- a/dap-chrome.el +++ b/dap-chrome.el @@ -50,7 +50,7 @@ (setq conf (-> conf (plist-put :type "chrome") (plist-put :dap-server-path dap-chrome-debug-program) - (dap--put-if-absent :cwd (expand-file-name default-directory)))) + (dap--put-if-absent :cwd default-directory))) (dap--plist-delete (pcase (plist-get conf :mode) ("url" (-> conf diff --git a/dap-mode.el b/dap-mode.el index 77e20b08..290abab0 100644 --- a/dap-mode.el +++ b/dap-mode.el @@ -1590,7 +1590,8 @@ before starting the debug process." :wait-for-port :type :request :port :startup-function :environment-variables :hostName host) launch-args) (session-name (dap--calculate-unique-name name (dap--get-sessions))) - (default-directory (or cwd default-directory)) + (default-directory (or (and cwd (expand-file-name cwd)) + default-directory)) (process-environment (if environment-variables (cl-copy-list process-environment) process-environment)) From 6d699abcd2b2b888ff736f8e953c00fa69fef1a7 Mon Sep 17 00:00:00 2001 From: Nikita Bloshchanevich Date: Thu, 26 Nov 2020 21:36:26 +0100 Subject: [PATCH 2/2] `dap-start-debugging-noexpand': expanded :cwd In `dap-start-debugging-noexpand', also `expand-file-name' `default-directory' if `:cwd' is unspecified. Additionally, always send a fully expanded :cwd based on the `default-directory' obtained above to the adapter. --- dap-mode.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/dap-mode.el b/dap-mode.el index 290abab0..8f9b0957 100644 --- a/dap-mode.el +++ b/dap-mode.el @@ -1590,8 +1590,7 @@ before starting the debug process." :wait-for-port :type :request :port :startup-function :environment-variables :hostName host) launch-args) (session-name (dap--calculate-unique-name name (dap--get-sessions))) - (default-directory (or (and cwd (expand-file-name cwd)) - default-directory)) + (default-directory (expand-file-name (or cwd default-directory))) (process-environment (if environment-variables (cl-copy-list process-environment) process-environment)) @@ -1623,15 +1622,18 @@ before starting the debug process." (dap--set-sessions (cons debug-session debug-sessions))) (dap--send-message - (dap--make-request request (-> launch-args - (cl-copy-list) - (dap--plist-delete :cleanup-function) - (dap--plist-delete :startup-function) - (dap--plist-delete :dap-server-path) - (dap--plist-delete :environment-variables) - (dap--plist-delete :wait-for-port) - (dap--plist-delete :skip-debug-session) - (dap--plist-delete :program-to-start))) + (dap--make-request request (cl-list* + :cwd default-directory + (-> launch-args + (cl-copy-list) + (dap--plist-delete :cwd) + (dap--plist-delete :cleanup-function) + (dap--plist-delete :startup-function) + (dap--plist-delete :dap-server-path) + (dap--plist-delete :environment-variables) + (dap--plist-delete :wait-for-port) + (dap--plist-delete :skip-debug-session) + (dap--plist-delete :program-to-start)))) (dap--session-init-resp-handler debug-session) debug-session))) debug-session)