Skip to content

Commit

Permalink
Add support for hl-line-mode
Browse files Browse the repository at this point in the history
Due to dape's execution model (timer based) point is moved after
post-command-hook is evaled, therefore we are stealing the
implementation from gud.el to add hl-line support.

Fixes #147
  • Loading branch information
svaante committed Sep 3, 2024
1 parent 6a78de9 commit 23128f8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion dape.el
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
(define-obsolete-variable-alias 'dape-update-ui-hooks 'dape-update-ui-hook "0.13.0")
(define-obsolete-variable-alias 'dape-compile-compile-hooks 'dape-compile-hook "0.13.0")


;;; Forward declarations
(defvar hl-line-mode)
(defvar hl-line-sticky-flag)
(declare-function global-hl-line-highlight "hl-line" ())
(declare-function hl-line-highlight "hl-line" ())


;;; Custom
(defgroup dape nil
Expand Down Expand Up @@ -3244,7 +3251,7 @@ See `dape-request' for expected CB signature."
(when-let ((window
(display-buffer (marker-buffer marker)
dape-display-source-buffer-action)))
;; Change selected window if not dape-repl buffer is selected
;; Change selected window if not `dape-repl' buffer is selected
(unless (with-current-buffer (window-buffer)
(memq major-mode '(dape-repl-mode)))
(select-window window))
Expand All @@ -3253,6 +3260,17 @@ See `dape-request' for expected CB signature."
;; context. But this makes tests to hard write.
(with-selected-window window
(goto-char (marker-position marker))
;; This code is running within the timer context
;; rather than the command context. Since the
;; `post-command-hook' is executed before the point
;; (cursor position) is actually updated, we must
;; manually intervene to account for this. The
;; following logic borrows from gud.el to interact
;; with `hl-line'.
(when (featurep 'hl-line)
(cond
(global-hl-line-mode (global-hl-line-highlight))
((and hl-line-mode hl-line-sticky-flag) (hl-line-highlight))))
(run-hooks 'dape-display-source-hook)))))))))


Expand Down

0 comments on commit 23128f8

Please sign in to comment.