Skip to content

Commit 2ae491d

Browse files
committed
Cleanup completion buffers
1 parent e07de7b commit 2ae491d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

js-comint.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ Each should be a plist with last-prompt-start, type, function, arguments")
299299
(prog1 ""
300300
;; ensure the buffer is active
301301
(unless (bufferp js-comint--completion-buffer)
302-
;; TODO this buffer should probably be killed on exit
303302
(setq js-comint--completion-buffer (generate-new-buffer " *js-comint completion*" t)))
304303
(with-current-buffer js-comint--completion-buffer
305304
(goto-char (point-max))
@@ -667,6 +666,11 @@ If no region selected, you could manually input javascript expression."
667666
(setq company-backends
668667
(delete #'company-js-comint company-backends))))
669668

669+
(defun js-comint--cleanup ()
670+
"Runs after comint buffer is killed."
671+
(when js-comint--completion-buffer
672+
(kill-buffer js-comint--completion-buffer)))
673+
670674
;;;###autoload
671675
(define-derived-mode js-comint-mode comint-mode "Javascript REPL"
672676
:group 'js-comint
@@ -678,6 +682,7 @@ If no region selected, you could manually input javascript expression."
678682
(setq comint-input-ignoredups t)
679683
(add-hook 'comint-output-filter-functions 'js-comint-filter-output nil t)
680684
(add-hook 'comint-preoutput-filter-functions #'js-comint--async-output-filter nil t)
685+
(add-hook 'kill-buffer-hook #'js-comint--cleanup nil t)
681686
(process-put (js-comint-get-process)
682687
'adjust-window-size-function (lambda (_process _windows) ()))
683688
(use-local-map js-comint-mode-map)

0 commit comments

Comments
 (0)