Fix #3760: bind SPC m d only when debugger is active

This commit is contained in:
Henrik Lissner 2020-08-20 17:23:45 -04:00
parent 9e9b95f49c
commit bf4929f4df
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -120,8 +120,31 @@
(dap-mode 1)
(define-minor-mode +dap-running-session-mode
"A mode for adding keybindings to running sessions"
nil nil (make-sparse-keymap)
(when (bound-and-true-p evil-mode)
(evil-normalize-keymaps)) ; if you use evil, this is necessary to update the keymaps
;; The following code adds to the dap-terminated-hook so that this minor
;; mode will be deactivated when the debugger finishes
(when +dap-running-session-mode
(let ((session-at-creation (dap--cur-active-session-or-die)))
(add-hook 'dap-terminated-hook
(lambda (session)
(when (eq session session-at-creation)
(+dap-running-session-mode -1)))))))
;; Activate this minor mode when dap is initialized
(add-hook 'dap-session-created-hook #'+dap-running-session-mode)
;; Activate this minor mode when hitting a breakpoint in another file
(add-hook 'dap-stopped-hook #'+dap-running-session-mode)
;; Activate this minor mode when stepping into code in another file
(add-hook 'dap-stack-frame-changed-hook (lambda (session)
(when (dap--session-running session)
(+dap-running-session-mode 1))))
(map! :localleader
:map dap-mode-map
:map +dap-running-session-mode
"d" #'dap-hydra))