Skip to content

Commit

Permalink
Show reason for stoppage in mode-line
Browse files Browse the repository at this point in the history
  • Loading branch information
svaante committed Apr 20, 2024
1 parent dbe9f13 commit 7434d74
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions dape.el
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,9 @@ See `dape--connection-selected'."
(state
:accessor dape--state :initform nil
:documentation "Session state.")
(state-reason
:accessor dape--state-reason :initform nil
:documentation "Reason for state.")
(exception-description
:accessor dape--exception-description :initform nil
:documentation "Exception description.")
Expand Down Expand Up @@ -1834,27 +1837,24 @@ Sets `dape--thread-id' from BODY and invokes ui refresh with
(&key threadId reason allThreadsStopped hitBreakpointIds
&allow-other-keys)
body
(dape--update-state conn 'stopped)
(dape--update-state conn 'stopped reason)
(dape--maybe-select-thread conn threadId 'force)
;; Reset stack id to force a new frame in
;; `dape--current-stack-frame'.
(setf (dape--stack-id conn) nil
;; Reset exception description
(dape--exception-description conn) nil)
;; Important to do this before `dape--update' to be able to setup
(pcase reason
;; Output exception info in overlay and repl
("exception"
(let* ((texts
(seq-filter 'stringp
(list (plist-get body :text)
(plist-get body :description))))
(str (mapconcat 'identity texts ":\n\t")))
(setf (dape--exception-description conn) str)
(dape--repl-message str 'dape-repl-error-face)))
(_
;; TODO Would be nice to display other `reasons'
))
;; breakpoints description.
(when (equal reason "exception")
;; Output exception info in overlay and REPL
(let* ((texts
(seq-filter 'stringp
(list (plist-get body :text)
(plist-get body :description))))
(str (mapconcat 'identity texts ":\n\t")))
(setf (dape--exception-description conn) str)
(dape--repl-message str 'dape-repl-error-face)))
;; Update breakpoints hits
(dape--breakpoints-stopped hitBreakpointIds)
;; Update `dape--threads'
Expand Down Expand Up @@ -4776,9 +4776,10 @@ See `eldoc-documentation-functions', for more infomation."

;;; Mode line

(defun dape--update-state (conn state)
(defun dape--update-state (conn state &optional reason)
"Update Dape mode line with STATE symbol for adapter CONN."
(setf (dape--state conn) state)
(setf (dape--state-reason conn) reason)
(force-mode-line-update t))

(defun dape--mode-line-format ()
Expand All @@ -4791,6 +4792,9 @@ See `eldoc-documentation-functions', for more infomation."
(format "%s" (or (and conn (dape--state conn))
'unknown))
'face 'font-lock-doc-face)
(when-let ((reason (and conn (dape--state-reason conn))))
(format "[%s]" (propertize reason
'face 'font-lock-doc-face)))
(when-let* ((conns (dape--live-connections))
(nof-conns
(length (cl-remove-if-not 'dape--threads conns)))
Expand Down

0 comments on commit 7434d74

Please sign in to comment.