branch: externals/eglot
commit fadf7594e93def4fc60d403441aa1812bcc1e38e
Author: João Távora <[email protected]>
Commit: João Távora <[email protected]>

    Fix #633, #1067: Don't exceed max-specdl-size in big Go projects
    
    When invoking client/registerCapability for
    workspace/didChangeWatchedFiles, Gopls lists each file to watch
    separately.  This makes eglot--glob-emit-{} emit a closure with an
    'or' form containing a potentially large number of 're-search-forward'
    forms.
    
    For large Go project such as "Kubernetes", this list becomes so large
    that -- for some reason I don't understand -- it triggers the
    'max-specdl-size' limit.
    
    An alternative using `regexp` opt doesn't seem to trigger the error.
    
    * eglot.el (eglot--glob-emit-{}): Use regexp-opt.
---
 eglot.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/eglot.el b/eglot.el
index 493bfcc7d6..038847c78f 100644
--- a/eglot.el
+++ b/eglot.el
@@ -3260,8 +3260,7 @@ If NOERROR, return predicate, else erroring function."
 (defun eglot--glob-emit-{} (arg self next)
   (let ((alternatives (split-string (substring arg 1 (1- (length arg))) ",")))
     `(,self ()
-            (or ,@(cl-loop for alt in alternatives
-                           collect `(re-search-forward ,(concat "\\=" alt) nil 
t))
+            (or (re-search-forward ,(concat "\\=" (regexp-opt alternatives)) 
nil t)
                 (error "Failed matching any of %s" ',alternatives))
             (,next))))
 

Reply via email to