[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 398b81e 35/49: Per #602: simplify dir-watching st
From: |
Stefan Monnier |
Subject: |
[elpa] externals/eglot 398b81e 35/49: Per #602: simplify dir-watching strategy of w/didChangeWatchedFiles |
Date: |
Wed, 17 Mar 2021 18:41:48 -0400 (EDT) |
branch: externals/eglot
commit 398b81eeec44b35b39480a38f1b1357bc8550a1c
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Per #602: simplify dir-watching strategy of w/didChangeWatchedFiles
Instead of massaging the globPattern to match directories instead of
files, which is fragile, gather the list of directoris to watch by
matching the globPattern against every file recursively (except hidden
files and dirs).
This is still not 100% correct, but should do the right thing is most
cases. Notably, if the correct dirs are being watched, the glob
pattern is matched against all existing and new files in those
directories, which does include hidden files.
* eglot.el (eglot-register-capability): match file globs against
files only.
(eglot--files-recursively): Rename from eglot--directories-recursively.
---
eglot.el | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/eglot.el b/eglot.el
index 90d973c..80780f5 100644
--- a/eglot.el
+++ b/eglot.el
@@ -2612,25 +2612,20 @@ at point. With prefix argument, prompt for
ACTION-KIND."
(let* (success
(globs (mapcar
(eglot--lambda ((FileSystemWatcher) globPattern)
- (cons
- (eglot--glob-compile globPattern t t)
- (eglot--glob-compile
- (replace-regexp-in-string "/[^/]*$" "/" globPattern) t
t)))
+ (eglot--glob-compile globPattern t t))
watchers))
(dirs-to-watch
- (cl-loop for dir in (eglot--directories-recursively)
- when (cl-loop for g in globs
- thereis (ignore-errors (funcall (cdr g) dir)))
- collect dir)))
+ (cl-loop for f in (eglot--files-recursively)
+ when (cl-loop for g in globs thereis (funcall g f))
+ collect (file-name-directory f) into dirs
+ finally (cl-return (delete-dups dirs)))))
(cl-labels
((handle-event
(event)
(pcase-let ((`(,desc ,action ,file ,file1) event))
(cond
((and (memq action '(created changed deleted))
- (cl-find file (mapcar #'car globs)
- :test (lambda (f glob)
- (funcall glob f))))
+ (cl-find file globs :test (lambda (f g) (funcall g f))))
(jsonrpc-notify
server :workspace/didChangeWatchedFiles
`(:changes ,(vector `(:uri ,(eglot--path-to-uri file)
@@ -2724,14 +2719,14 @@ If NOERROR, return predicate, else erroring function."
(when (eq ?! (aref arg 1)) (aset arg 1 ?^))
`(,self () (re-search-forward ,(concat "\\=" arg)) (,next)))
-(defun eglot--directories-recursively (&optional dir)
+(defun eglot--files-recursively (&optional dir)
"Because `directory-files-recursively' isn't complete in 26.3."
(cons (setq dir (expand-file-name (or dir default-directory)))
- (cl-loop
- with default-directory = dir
- with completion-regexp-list = '("^[^.]")
- for f in (file-name-all-completions "" dir)
- when (file-directory-p f) append (eglot--directories-recursively f))))
+ (cl-loop with default-directory = dir
+ with completion-regexp-list = '("^[^.]")
+ for f in (file-name-all-completions "" dir)
+ if (file-name-directory f) append (eglot--files-recursively f)
+ else collect (expand-file-name f))))
;;; Rust-specific
- [elpa] externals/eglot 147f3b0 16/49: Close #411: offer shortcut commands to commonly invoked code actions, (continued)
- [elpa] externals/eglot 147f3b0 16/49: Close #411: offer shortcut commands to commonly invoked code actions, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 99f8d7b 17/49: Per #604: mention common installation pitfalls in README.md, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 2879b83 19/49: * README.md: Mention Google Open Source Peer Bonus, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot d5b840b 20/49: Fix #606, #Fix 608: fix bug in eglot-code-actions, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot eac5264 21/49: Fix #609: flush pending changes to server before code actions request, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot f68f829 26/49: Close #566: prefer typescript-language-server for JS&TS, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot c73f5ed 27/49: Fix #612: remove duplicate entry for "Registration" LSP type, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 4ae5a44 28/49: Fix #568: update gopls URL in README.md, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 8d00f8b 32/49: Per #602: speed up glob matching 2x, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot e57be55 36/49: Fix #502: silence messages while formatting markup, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 398b81e 35/49: Per #602: simplify dir-watching strategy of w/didChangeWatchedFiles,
Stefan Monnier <=
- [elpa] externals/eglot a2d1fc9 37/49: Fix #625: handle null reply for textDocument/definition, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 92b0c5d 41/49: Fix #610: protect against empty URIs on windows, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot ee980cf 39/49: Fixup last commit to fix #627, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 47f8581 47/49: Per #605: indicate support for activeParameter, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot f0c770c 48/49: Fix #555: autoload eglot-workspace-configuration's safe-l-v spec, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot f63abe8 30/49: Fix #418: support phps-mode, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot d784d60 42/49: Fix #635: Correctly protect against zero-length completion items, Stefan Monnier, 2021/03/17
- [elpa] externals/eglot 39473f7 45/49: Fix #626: remove highlight overlays immediately when symbol edited, Stefan Monnier, 2021/03/17