From ffabd2687bf3f04a5122314bfba98e8719ffd8ef Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 9 May 2018 12:49:09 +0200 Subject: [PATCH] lang/javascript: refactor & document +javascript/cleanup-tide-processes --- modules/lang/javascript/autoload.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/lang/javascript/autoload.el b/modules/lang/javascript/autoload.el index 7e03d5749..2cf22ab83 100644 --- a/modules/lang/javascript/autoload.el +++ b/modules/lang/javascript/autoload.el @@ -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)))))