emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/eglot 6a7ce66 32/69: Expand directory watcher globs con


From: João Távora
Subject: [elpa] externals/eglot 6a7ce66 32/69: Expand directory watcher globs containing ** (#293)
Date: Sun, 20 Oct 2019 08:21:47 -0400 (EDT)

branch: externals/eglot
commit 6a7ce6634fcf79853a6bd89cf1c81bad2ac25540
Author: Jürgen Hötzel <address@hidden>
Commit: João Távora <address@hidden>

    Expand directory watcher globs containing ** (#293)
    
    Previously, if the server requested a glob pattern like foo/**/*
    to be watched, we would just error.  Now we watch foo/bar/ and
    foo/baz/ as if the server had requested those two watchers
    instead of just the one with the **.
    
    As a limitation, the implementation of file-expand-wildcards
    doesn't fully handle ** globstars (** matches at most one path
    segment).
    
    * eglot.el (eglot-register-capability workspace/didChangeWatchedFiles):
    Use file-expand-wildcards to make a ** glob into multiple **-less
    globs.
---
 eglot.el | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/eglot.el b/eglot.el
index a80be22..6078e97 100644
--- a/eglot.el
+++ b/eglot.el
@@ -2371,7 +2371,10 @@ If SKIP-SIGNATURE, don't try to send 
textDocument/signatureHelp."
   (let* (success
          (globs (mapcar (eglot--lambda ((FileSystemWatcher) globPattern)
                           globPattern)
-                        watchers)))
+                        watchers))
+        (glob-dirs
+         (delete-dups (mapcar #'file-name-directory
+                              (mapcan #'file-expand-wildcards globs)))))
     (cl-labels
         ((handle-event
           (event)
@@ -2394,13 +2397,14 @@ If SKIP-SIGNATURE, don't try to send 
textDocument/signatureHelp."
               (handle-event '(desc 'deleted file))
               (handle-event '(desc 'created file1)))))))
       (unwind-protect
-          (progn (dolist (dir (delete-dups (mapcar #'file-name-directory 
globs)))
-                   (push (file-notify-add-watch dir '(change) #'handle-event)
-                         (gethash id (eglot--file-watches server))))
-                 (setq
-                  success
-                  `(:message ,(format "OK, watching %s watchers"
-                                      (length watchers)))))
+          (progn
+           (dolist (dir glob-dirs)
+             (push (file-notify-add-watch dir '(change) #'handle-event)
+                   (gethash id (eglot--file-watches server))))
+           (setq
+            success
+            `(:message ,(format "OK, watching %s directories in %s watchers"
+                                (length glob-dirs) (length watchers)))))
         (unless success
           (eglot-unregister-capability server method id))))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]