Skip to content

Commit

Permalink
Handle window buffer changing
Browse files Browse the repository at this point in the history
Example bug: Edit. C-c C-c such that the REPL buffer replaces the edit
buffer in the same window. Or, invoke magit and the magit buffer
replaces the edit buffer in the same window.

See also commit 689d0a6
  • Loading branch information
greghendershott committed Apr 26, 2023
1 parent 953594a commit 78527ec
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions racket-pdb.el
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ for the annotations resulting from the user's later edits.")
(run-with-idle-timer racket-pdb-after-change-refresh-delay
nil ;no repeat
#'racket--pdb-on-change-idle-timer
(selected-window)))))
(selected-window)
(current-buffer)))))

(defun racket--pdb-on-change-idle-timer (window)
(defun racket--pdb-on-change-idle-timer (window buffer)
"Handle after-change-hook => idle-timer expiration.
One scenario to keep in mind: The user has typed a few characters
Expand All @@ -367,12 +368,12 @@ and might miss a change from before they even started completion
-- which is not great, but is better than making a mistake
rescheduling an idle-timer with an amount <= the amount of idle
time that has already elapsed: see #504."
(let ((buffer (window-buffer window)))
(when (buffer-live-p buffer)
(with-current-buffer buffer
(unless (racket--pdb-completing-p)
(with-selected-window window
(racket-pdb-analyze)))))))
(when (and (buffer-live-p buffer)
(equal buffer (window-buffer window)))
(with-current-buffer buffer
(unless (racket--pdb-completing-p)
(with-selected-window window
(racket-pdb-analyze))))))

(defun racket--pdb-completing-p ()
"Is completion underway?
Expand Down

0 comments on commit 78527ec

Please sign in to comment.