lang/javascript: refactor & document +javascript/cleanup-tide-processes

This commit is contained in:
Henrik Lissner 2018-05-09 12:49:09 +02:00
parent e33a3b2c63
commit ffabd2687b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -102,12 +102,15 @@ If it's found, then add it to the `exec-path'."
;;;###autoload
(defun +javascript|cleanup-tide-processes ()
"TODO"
"Clean up dangling tsserver processes if there are no more buffers with
`tide-mode' active that belong to that server's project."
(when tide-mode
(unless (cl-loop with root = (tide-project-root)
(unless (cl-loop with project-name = (tide-project-name)
for buf in (delq (current-buffer) (buffer-list))
if (buffer-local-value 'tide-mode buf)
collect buf)
if (and (buffer-local-value 'tide-mode buf)
(with-current-buffer buf
(string= (tide-project-name) project-name)))
return buf)
(kill-process (tide-current-server)))))